In what date format is 1339698600000 = 15 June 2012? - datetime

I am using bootstrap-datepicker and get a value of 1339698600000 for the selected date of 15th June 2012.
What dateformat is this? How do I convert it to human readable format?
Is there any resource where I can find many more formats?

That is the number of milliseconds since January 1, 1970 (POSIX epoch). You can divide it by 1000 to get the number of seconds since epoch which is a standard way to represent time.

It's the number of milliseconds since 1/1/1970. To convert to human readable, Add that many milliseconds to a 1/1/1970 date object.

Related

How to deal with "YYYY-MM-DD HH:MM:SS.SSS +0000" format in SQLite?

I have two columns, DATE_A and DATE_B.
I need to find how much time is between the two dates.
Usually, I would use JULIANDAY() and subtract one date from another, but the output is null because of the "+0000" part.
Below you'll find an example of values contained in the two columns:
DATE_A - '2022-05-12 00:16:17.553 +0000'
DATE_B - '2022-06-02 00:02:01.158 +0000'
Please tell me what '+0000' means and how can I find the time elapsed between the two dates.
+0000 is the offset from UTC this time represents in hours and minutes. For example, here in the US Pacific it's daylight savings time and we're 7 hours behind UTC so we're -0700. 2022-05-12 08:00:00+0000 and 2022-05-12 01:00:00-0700 are the same point in time.
SQLite will accept a slightly different format. There has to be the : separator between hours and minutes.
2022-05-12 00:16:17.553 +00:00
^
You'll have to change the format. Use your programming language's date and time functions.
See "Time Values" in SQLite Date and Time Functions for valid formats.

What date format is 636529536000000000?

I have to maintain an ASPX page that increments the date/time by passing a value in the querystring in this format:
636529536000000000 in reference to 31 January 2018
636530400000000000 in reference to 01 February 2018
The url format is: /reservas.aspx?t=636530400000000000
What is this date/time format?
It is the number of ticks where a tick is one hundred nanoseconds or one ten-millionth of a second. The number of ticks is measured since the epoch DateTime.MinValue (12:00:00 midnight, January 1, 0001). For example:
new DateTime(636529536000000000).ToString("F", CultureInfo.InvariantCulture)
outputs:
Wednesday, 31 January 2018 00:00:00
Could be a number of days from certain date, similar to julian date calculation:
https://en.wikipedia.org/wiki/Julian_day#Julian_date_calculation
Potentially incorporating the time as well?
Without details of the code I cant really advise from a provided value.

Is IDL able to add / subtract from date?

As you can see the question above, I was wondering if IDL is able to add or subtract days / months / years to a given date.
For example:
given_date = anytim('01-jan-2000')
print, given_date
1-Jan-2000 00:00:00.000
When I would add 2 weeks to the given_date, then this date should appear:
15-Jan-2000 00:00:00.000
I was already looking for a solution for this problem, but I unfortunately couldn't find any solution.
Note:
I am using a normal calendar date, not the julian date.
Are you only concerned with dates after 1582? Is accuracy to the second important?
The ANYTIM routine is not part of the IDL distribution. Possibly there are third party routines to handle time increments, but I don't know of any builtin to the IDL library.
By default, which you are using, ANYTIM returns seconds from Jan 1, 1979. So to add/subtract some number of days, weeks, or years, you could calculate the number of seconds in the time interval. Of course, this does not take into account leap seconds/years (but leap years are fairly easy to take into account, leap seconds requires a database of when they were added). And adding months is going to require determining which month so to determine the number of days in it.
IDL can convert to and from Julian dates using JULDAY and CALDAT.
You may also read and write Julian dates (which are doubles or long integers) to and from strings using the format keyword to PRINT, STRING, and READS.
You'll want to use the (C()) calendar date format code.
format='(c(cdi0,"-",cMoa,"-"cyi04," ",cHi02,":",cmi02,":",csf06.3))'
date = julday(1, 1, 2000)
print, date, format=format
; 1-Jan-2000 00:00:00.000
date = date + 14
print, date, format=format
; 15-Jan-2000 00:00:00.000

What is the format of Chrome's timestamps?

I'm using SQLite Database Browser to read information from a database containing the browsing history for Google Chrome. My current code that I am executing in the "Execute SQL" panel looks like this:
SELECT last_visit_time,url,title
FROM urls
WHERE url LIKE {PLACEHOLDER} AND title LIKE {PLACEHOLDER}
The stuff on the "WHERE" line is blocked out with {PLACEHOLDER} for privacy purposes. Now, I want to make it such that the data returned in the last_visit_time column is readable instead of a jumbled mess like 13029358986442901. How do I do this and how do I convert Chrome's timestamp to a readable format? How do I get it to order them (the returned rows) by last_visit_time?
The answer is given in this question: "[Google Chrome's] timestamp is formatted as the number of microseconds since January, 1601"
So for example in my sample history database, the query
SELECT
datetime(visit_time / 1000000 + (strftime('%s', '1601-01-01')), 'unixepoch', 'localtime')
FROM visits
ORDER BY visit_time DESC
LIMIT 10;
gives the results:
2014-09-29 14:22:59
2014-09-29 14:21:57
2014-09-29 14:21:53
2014-09-29 14:21:50
2014-09-29 14:21:32
2014-09-29 14:21:31
2014-09-29 14:16:32
2014-09-29 14:16:29
2014-09-29 14:15:05
2014-09-29 14:15:05
Using your timestamp value of 13029358986442901:
SELECT
datetime(13029358986442901 / 1000000 + (strftime('%s', '1601-01-01')), 'unixepoch', 'localtime')
the result is:
2013-11-19 18:23:06
visits.visit_time is in microseconds since January 1, 1601 UTC which is similar but not to be mistaken for Windows filetime which is the number of 100 nanoseconds since January 1, 1601 UTC.
Trivia: Why 1601?
I think the popular answer is because the Gregorian calendar operates on a 400-year cycle, and 1601 is the first year of the cycle that was active at the time Windows NT was being designed. In other words, it was chosen to make the math come out nicely. January 1, 1601 is origin of COBOL integer dates. It is also day 1 by ANSI date format. And if you speculate further according to ISO8601 which is the format in which it is in, ISO8601 works as far back as the year 1581. Prior to 1583 time was based on the proleptic Gregorian calendar which has 366 days per year. Perhaps they just rounded up to the next century.
downloads.start_time is the number of seconds since January 1, 1970 UTC
Trivia: Why 1970?
Well, I'm glad you asked.. It didn't used to be.. Originally it was January 1, 1971 but was later rounded to January 1, 1970. January 1, 1970 is considered to be the birth of UNIX.
It's worth noting that Firefox formats time as the number of microseconds since January 1, 1970 and the name for the format is PRTime
All of these are in an ISO 8601 EPOCH format.
Chromes Timestap is not Unixepoch!!
Chrome's base time is 01/01/1601 00:00:00. To calculate local time, Chrome time has to be converted to seconds by dividing by one-million, and then the seconds differential between 01/01/1601 00:00:00 and 01/01/1970 00:00:00 must be subtracted. There are two ways you can do this, viz SQLite itself and Unix.
SQLITE:
sqlite> SELECT strftime('%s', '1601-01-01 00:00:00');
-11644473600
DATE:
$ date +%s -d 'Jan 1 00:00:00 UTC 1601'
-11644473600
In both commands above, the "%s" represents unixepoch time. The commands calculate the number of seconds between unixepoch time (1970) and the subsequent date (Chrome time base, 1601). Note that the seconds are negative. Of course, this is because you have to count backwards from 1970 to 1601! With this information, we can convert Chrome time in SQLite like this:
sqlite> SELECT datetime((time/1000000)-11644473600, 'unixepoch', 'localtime') AS time FROM table;
Have a good read here.
Here is a compact expression to convert WebKit Time:
sqlite> SELECT datetime(time/1e6-11644473600,'unixepoch','localtime') AS time FROM table;
I'm new to coding so I'm not sure how you do it with sql, however I can show you a method in c#. I am hoping this would help someone.
If the time value given in the database is :
13029358986442901. Select only the first 11 digits 13029358986. You can convert this to time using :
DateTime dateTimeVar = new DateTime(1601,1,1).AddSeconds(time);
The answer here was : 19-11-2013 18:23:06
And this was without your time zone conversion.
You can substract 11644473600000 (1/1/1601 is -11644473600000 in unixepoch) and treat it as a regulat unix epoch timestamp this is assuming miliseconds.
milis: 11644473600000
seconds: 11644473600

Converting datetime character string to double value of milliseconds since 1 Jan 1960

I've found out how to convert a Stata datetime format from milliseconds since Jan 1960 in R from a related question (see below):
as.POSIXct(874022400000/1000, origin="1960-01-01")
I am looking to do the opposite in R: i.e. given a datetime expressed as a character string, find out how to return the datetime value as milliseconds since 01 Jan 1960 00:00:00. Any suggestions would be much appreciated.
Use as.numeric to coerce the date-time back into seconds since the epoch. Since R uses 1970 as its origin, you have to additionally account for the 1960-1970 offset. Lastly, of course, take care of the seconds to milliseconds conversion.
> mydate = as.POSIXct(874022400000/1000, origin="1960-01-01")
> 1000 * (as.numeric(mydate) - as.numeric(as.POSIXct('1960-01-01')))
[1] 874022400000

Resources