Answer the question
In order to leave comments, you need to log in
how to format date in javascript?
I receive data from the database, there is a time graph in the format:
Fri Oct 02 2015 00:45:59 GMT+0300 (EEST)
But the client time is completely different.
You need to get the correct time (same as from the database) in the дд/мм/гггг чч:мм:сс
.
Answer the question
In order to leave comments, you need to log in
var d = new Date('Fri Oct 02 2015 00:45:59 GMT+0300 (EEST)');
var formatDate = ('0' + d.getDate()).slice(-2) + '/' + ('0' + (d.getMonth() + 1)).slice(-2) + '/' + d.getFullYear() + ' ' + ('0' + d.getHours()).slice(-2) + ':' + ('0' + d.getMinutes()).slice(-2) + ':' + ('0' + d.getSeconds()).slice(-2);
console.log(formatDate); // 02/10/2015 00:45:59
SELECT DATE_FORMAT(`my_date_column`, '%d/%m/%Y %H:%i:%s') AS `foramt_date` FROM `my_table`;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question