I am trying to built a attendance app for my college where in I am fetching data for a web time-table application which has a sql backend and there the lecture start time and end time is in format 1518427800
. I am not even sure what format is this.
I am using node.js to fetch from mysql and push it in firebase database, but before i pushing it in firebase. i want to convert the datetime format into something that is understandable.
I am not allowed to alter anything in the web application or its database.
It is a unix time stamp and represents the number of seconds since 1970-01-01.
You can just convert it to a number of milliseconds and pass it to the Date
constructor:
var datetime = new Date(1518427800 * 1000);
As mentioned in the above answer, it is a UNIX timestamp
Using moment it is very easy to convert into a readable format
const moment = require('moment')
moment(1553939271155).format("DD/MM/YYYY") // outputs "30/03/2019"
moment(1553939271155).format("DD/MMM/YYYY") // outputs "30/Mar/2019"
moment(1553939037562).format("YYYY/MM/DD") // outputs "2019/03/30"
1518427800 is an epoch timestamp. It is the number of seconds since jan 1 1970.
you can simply convert it into the number of milliseconds
ex. 1518427800*1000
then , pass it to the DATE constructor
ex. var datetime = new Date(1518427800 * 1000);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.