prista
prista

Reputation: 381

Timestamp to date with Javascript. How?

I create a timestamp with strtotime php function. My question is how to "reverse" timestamp to year, month, date, ... seconds etc using javascript ?

Upvotes: 0

Views: 4843

Answers (3)

Zakaria
Zakaria

Reputation: 15070

var date = new Date(phptimestamp*1000);
var hours = date.getHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
//etc...

Upvotes: 1

sharpner
sharpner

Reputation: 3937

var date = new Date(timestamp*1000);

Upvotes: 0

Robby Pond
Robby Pond

Reputation: 73484

var date = new Date(seconds*1000);

where milliseconds is seconds since Jan 1970.

Upvotes: 0

Related Questions