J
J
j_seitaliev2015-10-29 11:58:33
JavaScript
j_seitaliev, 2015-10-29 11:58:33

How to convert date string using js?

How to convert date string using js?
Line type: Oct 26 2015 08:30:50:730PM

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Denis Ineshin, 2015-10-29
@IonDen

Best with Moment.js

A
Alexey Tsarapkin, 2015-10-29
@Dreamka

You can use phpJS.
strtotime and date

date("Y-m-d", strtotime("Oct 26 2015 08:30:50:730PM"));

N
nozzy, 2015-10-29
@nozzy

Я делаю так, стороне сервера дату конвертирую в unix_timestamp
unix_timestamp( post_date )*1000
в javascript :
var d = new Date(parseInt(response.post_date));
var months = ['01','02','03','04','05','06','07','08','09','10','11','12'];
$('').html(d.getFullYear() + "-" + months[d.getMonth()] + "-" + d.getDate() ).appendTo(tr);
ну и еще - d.getSeconds();
d.getMinutes();
d.getHours();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question