I have the following php code that returns time in different time zone:
<?php
date_default_timezone_set('America/New_York');
echo (new DateTime())->format('r');
?>
and that works fine, when I run it in the browser I get the time:
Tue, 29 Sep 2015 12:07:01 -0400
Now, I have a jquery script that calls ajax this php page and displays it on my page. It starts like this:
$.ajax({
type: 'GET',
url: 'timeinnewyork.php',
complete: function(resp){
var today;
today = new Date(resp.responseText);
alert(resp.responseText);
alert(today);
(...)
and the first alert returns the time in new york:
Tue, 29 Sep 2015 12:07:27 -0400
but the second one shows me my current european timezone:
Tue Sep 29 2015 18:07:27 GMT+0200 (Central Europe Daylight Time)
I want to use the New York time and not my local time. How can I fix that?