Send date from PHP to Javascript -
I have already tried the question but my question was not resolved.
I have PHP server that sends a date to the user via JSON, where it is processed by Javascript:
PHP: 'date' = & Gt; Date ('DM DYH: Iso', strotom ($ array ['time']))
javascript var time = new date (data.date) toLocaleString ()
But instead of receiving the January 18, 2015 ... me, March 3, 5877521-596: -31: -23 GMT + 0: 53: 28. What's wrong there?
Some things you may need to know: There is a date sent along with the European time zone in the center of the server. I am trying to internationalize the date with javascript (above only is an example).
Why pass a string? The date maker of JS will accept a timestamp:
var time = new date (& lt ;? php echo strtotime ($ array ['time'])? Gt; 000); In this 000 note that JS returns back in seconds, whereas in the second Stratom returns , you can effectively construct Will:
var time = new date (12345678000); ^^^^^^^ --- ^^^ --- instant conversion from PHP
Comments
Post a Comment