Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript Date.now to readable format

Tags:

javascript

Date.now();

I want to convert the timestamp to readable format

e.g "Fri Nov 17 2017 19:15:15 GMT+0800 (Malay Peninsula Standard Time)"

like image 412
Rex Adrivan Avatar asked Nov 17 '17 11:11

Rex Adrivan


Video Answer


2 Answers

var date = new Date();
console.log(date.toLocaleDateString());
console.log(date.toDateString());
console.log(date.toGMTString());

Choose your method from here: https://www.w3schools.com/js/js_date_methods.asp

like image 120
jmtalarn Avatar answered Sep 22 '22 03:09

jmtalarn


You could do these following statements

let newDate = new Date(Date.now());
console.log(`${newDate.toDateString()} ${newDate.toTimeString()}`);
like image 22
Christophe Coquelet Avatar answered Sep 26 '22 03:09

Christophe Coquelet