javascript - How to convert a time format that I got from PHP to a format that jQuery countdown accepts -


I have such a time format, it is stored in my database .. and I want to convert it to a format I accept the countdown to JQuery. I think the jQuery countdown accepts this type of format

  Sun Jan 01 2012 00:00:00 GMT + 0800 (Malay Peninsula Standard Time)   

But the problem is, my time format is like this:

  2011-03-29 00:01:03   

In order of jQuery Hank Countdown to count, I need to convert a long format .. how to do it?

Here is the jQuery website

You do not need it in that long format , This is the same format that is output when you try to print javascript date objects.

You must create a Javascript

The basic way to do this is:

  var date = new date ([year], [month] , [Day]);   

Note: The month is zero indexed. That is January 0, is February 1, December 11.

So if you spit it using php.

  $ date = new dateTime ('2011-03 -29 00:01:03'); Format ('n') - 1, $ date- ('y'), 'date date', 'date date', 'date date = new date (% d,% d,% d);', $ date- & Gt; & Gt; Format ('J'), $ date-> Format ('H'), $ date-> Format ('i'), $ date- & gt; Format ('s')); Alternatively, you can pass it using json:  
  json_encode (array ('year' => = date- & gt; format ('y'), 'month '= & Gt; $ date- & gt; format (' n ') - 1,' day '=> date $ & gt; format (' j ')' hour '= & gt; $ date- & Format ('h'), 'min' =>> $ date-> format ('i'), 'second' => $ date- & gt; format ('s'))) ;   

Then create a date with javascript:

  var date = new date (json.year, json.month, json.day, json.hour, Json.minute, json.second);    

Comments