I get data from legacy API where there is a field 'opendate': 1086652416 I know that this is 24/06/2014
initially I have decide that this is unix_timestamp which should be multiply with 1000 and BINGO
Convert a Unix timestamp to time in JavaScript
var unix_timestamp = 1086652416;
var date = new Date(unix_timestamp*1000);
console.log(date); // Date {Tue Jun 08 2004 06:53:36 GMT+0700 (NOVST)}
// As you see this is not 24/06/2014 !!!
99% that this is datetime format from MSSQL and it should be 24/06/2014
from early results: 1066467328 is 2011-12-15, 1066598400 is 2011-12-16
the question is: how could I convert this datetime to format YYYY-mm-dd in NodeJS
From MSSQL documenation:
Values with the datetime data type are stored internally by Microsoft SQL Server as two 4-byte integers. The first 4 bytes store the number of days before or after the base date, January 1, 1900. The base date is the system reference date. Values for datetime earlier than January 1, 1753, are not permitted.