Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
19
rated 0 times [  20] [ 1]  / answers: 1 / hits: 25729  / 14 Years ago, sat, april 17, 2010, 12:00:00

Is it possible to have JavaScript compute a timestamp returned from PHP's time() function and present it in a readable format such as Sun, 18th April 2010 at 4:00 pm?


More From » php

 Answers
52

Use the Date object to do that:



new Date(<?php echo time(); ?>*1000)


You need to multiply the Unix timestamp by 1000 becuase Date expects the timestamp to be in milliseconds.



And to format the date, you can use this Date.format method (Date has none built in).


[#97049] Wednesday, April 14, 2010, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
adilene

Total Points: 395
Total Questions: 88
Total Answers: 109

Location: Indonesia
Member since Tue, Aug 3, 2021
3 Years ago
;