How does instagram calculate a week? - instagram

I have a past date for a private message that was sent on a Friday, but I noticed that Instagram changes the value for the "weeks ago" on Tuesdays for this message.
So, I got the 16 digit timestamp via a direct URL from instagram's data on https://instagram.com/api/v1/direct_share/inbox/ , then converted this timestamp to a human readable date, but the "weeks ago" value Instagram is showing does not make sense to me.
So, I'm confused how this "weeks ago" works, can someone explain?

Related

How to get stripe subscription current_period_end as date

My end goal is to check subscription.cancel_at_period_end for false and store subscription end date as a moment date object.
const subscriptionEndDate = moment(subscription.current_period_end);
This is the result field coming from stripe in test mode.
current_period_end: 1649650039
But even using new Date(subscription.current_period_end) is coming back as 1970-01-20T02:14:10.039Z
Is this not the field that is suppose to show when the next billing date is ?
Any thoughts? What am I missing ?
UPDATE:
I was just doing some testing and figured out if I multiply that value by 1000 it comes out to be 1649650039000 which equates to
Mon 11 April 2022 00:07:19
Is there a reason for this? Is this a safe method moving forward?
UPDATE:
I accepted answer below and am providing momentjs that converts directly to unix timestamp.
const date = moment(new Date()).unix();
Issue
Stripe reports date fields as Unix timestamps. These represent a date/time as the number of seconds since January 1, 1970 (kinda...leap seconds are weird).
The Javascript Date object attempts to convert the number of milliseconds since January 1, 1970 as that is an increment of time that is more relevant to front-end web coding.
Solution
You have already discovered an adequate solution, that is multiply the timestamp by 1000 and thereby convert the value in seconds to a value in milliseconds. This appears to be a common work around 1, 2, 3

Excel Date function and Time function in one formula

I have the following formula
DATE(YEAR(E687);MONTH(E687);DAY(E687))
and I want to use the TIME function as well. E.g:
DATE(YEAR(E687);MONTH(E687);DAY(E687)) - Time(10;0;0)
The reason is that I have guys working on my Excel sheetfrom CAT and PST
I am getting a date from the server and if a PST user adds data I want to minus 10 hrs from the server date to ensure I get the correct data in CAT.
I know my date above only shows date and not time but I want to remove 10hrs so see if it was done the previous day or the same day.
As comments on post suggests make sure your excels separation symbol e.g ; or , - Check regional settings.
Worked!

Wrong Date in SuiteScript

I want to get today's date in SuiteScript, when I type var tDate = new Date(); it shows me yesterday's date while debugging. I checked settings, there I couldn't see anything wrongly.
I am editing to this question. Most confusing thing is sometimes new Date () shows correct Date without any changes. No idea why it's acting like this. I added result of 'new Date()' as a picture right below.
In the first picture I captured on 1st of February, that shows me 31st of January which is wrong
In the second picture I captured today, that shows me today's date which is correct.
new Date() will give you the current timestamp according to the timezone of whatever system is running the code. In your browser console, new Date will give you the current timestamp in local time; in a server-side script, new Date will give you the current timestamp according to the timezone of your NetSuite data center.
How are you running this code, and what timezone are you yourself in?

How to get number of days between two dates in nodatime

I need to compute the number of days between two dates using NodaTime, and to do it in a timezone.
The end time is date based with an implied time of midnight at the end of the day. This date is in a timezone.
The start time is the current time, but I am passing it into the function so that the function is testable.
I tried using Period, which seems like the obvious answer, but Period is too granular on one end (when we are on the end day) and not granular enough when we are more than 1 month away.
So if Now is July 9, 5:45pm in America/Toronto and the End Time is Sept 1, 00:00:00, then I would like to be able to calculate 54 days. (assuming I counted the number of days on my calendar correctly. :) )
I figured I would have to handle the sub day problem myself, but it surprised me when I had to figure out how to handle the greater than a month problem.
Is there an obvious way to get the number of days between two times from NodaTime? I have it down to three lines of code using .Net's DateTime and TimezoneInfo classes, but I want to move to NodaTime for all the reasons specified on the site.
Thanks
I should have read the Arithmetic section of the docs more closely before posting.
You can specify which unit you want the math result to be in with a 3rd parameter. Here is what I needed:
Period timeLeft = Period.Between(nowInTz.LocalDateTime, endDate, PeriodUnits.Days);
this is from the docs:
http://nodatime.org/unstable/userguide/arithmetic.html
Hope this helps somebody else in the future.

Calculate time in all countries for fixed time in one of them

I have table with all countries GMT/UTC timezones, I need to see what time is in the rest of the countries when in USA is 11am-3pm
Not on particular date just know the difference in time.
I did my calculation like that I -5 GMT in USA and time is 11am then in Russia for example is +4 GMT.
5+4+11=20pm in Russia when USA is 11am, this works with countries that have + GMT zone but ones that have minus it shows wrong time.
I am working in Excel; please help me with advice on how to do it.
I did it already for the +gmt timezones and yes I have times for cities in big countries too; it was not my question.
How can I find out what time zone is in country with -11gmt when in country with +8gmt is 11am?
Someone know?
E.g. I work with dates like this in Excel. I set type of cell data to date and put
1/1/11 4:30 (+4:30 gmt)
1/1/11 1:00 (+1:00 gmt)
Now I have a date e.g. 1/20/11 11:00 (11 am on imaginary date); all I need to do is
"1/20/11 11:00 AM" - "1/1/11 4:30 AM" = "1/19/00 10:00 AM" at (0 gmt)
10am I don't really care about date in this case just time. I cannot think right now how I gound precise time but it seems somehow work without even putting +8 gmt in there...
Anyway solution should look something like that.
What about countries that have more than one time zone?
11am in the USA....where? West coast (PST) or east coast (EST)?
How do you take into consideration daylight savings time?
There are a lot of things to consider to do time conversions correctly.
I personally wouldn't keep a table with country and hour conversions, but two tables. One with timezones and hours from GMT time. And then another one with city names and timezone mappings. This way instead of converting from USA to Russia, you would be converting from New York to Moscow.
I did do a quick search on timezones in excel, and I found this article. I hope that it helps.

Resources