0

I am trying to figure out, how i can convert a unix timestamp to a readable date using javascript.

For an example, i want to convert this unix: 1422360000, to a date format like this (or something simular):

 Tue, 27 Jan 2015 12:00:00 GMT     

Solution:

 var timestamp = 1422360000;                 
 var date = new Date(timestamp * 1000);             
1

3 Answers 3

3

This is the exact solution to the question.

var timestamp = 1422360000;                 
var date = new Date(timestamp * 1000);

Result: Tue Jan 27 2015 13:00:00 GMT+0100

Sign up to request clarification or add additional context in comments.

Comments

1

Simply use Date(value)

value: Integer value representing the number of milliseconds since 1 January 1970 00:00:00 UTC (Unix Epoch).

Code

new Date(1422360000)

3 Comments

Using your solution, i get something like this: "1970-01-17T11:06:00.000Z"
@Englund0110, that's correct even I am getting said time.
It has to be Date(value*1000)
1

try this:

new Date(1422360000).toString()

That will make your date look like the string you want.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.