Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
176
rated 0 times [  179] [ 3]  / answers: 1 / hits: 40305  / 11 Years ago, sun, march 24, 2013, 12:00:00

Javascript:



I have object cell with something date



params.date = cell.getDate();
params.timestamp = cell.getDate().getTime() / 1000;
console.log(params);


Object {date: Thu May 09 2013 00:00:00 GMT+0800 (China Standard Time), timestamp: 1368028800}



Then I try to check timestamp in PHP



$date = '1368028800';
echo date('Y-m-d', $date);


2013-05-08



Difference in one day. Why?


More From » php

 Answers
45
params.date = cell.getDate();


Returns the DATE not the TIME.



params.timestamp = cell.getDate().getTime() / 1000;


is converting the date into a date+time - not reading the current time.



But even if you get the timestamp in javascript, the output of PHP's date function will depend on what timezone it is in.


[#79399] Friday, March 22, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tomas

Total Points: 165
Total Questions: 111
Total Answers: 103

Location: Maldives
Member since Tue, Dec 21, 2021
2 Years ago
tomas questions
Thu, Jan 27, 22, 00:00, 2 Years ago
Mon, May 10, 21, 00:00, 3 Years ago
Tue, Jan 5, 21, 00:00, 3 Years ago
;