1

I have a php script that returns date in tokyo in a following format:

Thu, 01 Oct 2015 06:10:09 +0900

I already passed it to my jquery script with ajax and now store it in local variable

var myTime = 'Thu, 01 Oct 2015 06:10:09 +0900

Now I want to create a new Date() object with that data, so then I can have an actual date from tokyo on my webpage without using local client's timezone. How can I do that?

user2314737
  • 27,088
  • 20
  • 102
  • 114
user3766930
  • 5,629
  • 10
  • 51
  • 104
  • 2
    Possible duplicate of http://stackoverflow.com/questions/22188215/jquery-pass-string-variable-to-date-object/ You also may want to reference the following: http://www.w3schools.com/jsref/jsref_obj_date.asp – Brandon White Sep 30 '15 at 21:18

1 Answers1

0

If your PHP code returns just that string:

<?PHP echo "Thu, 01 Oct 2015 06:10:09 +0900"; ?>

Then in your jQuery ajax return:

function(data) 
{
    var myDate = new Date(data.trim());
    //...
}//..

Example: of the raw string in jsfiddle JsFiddle

Rob22
  • 81
  • 6