Convert PHP date into javascript date format

Posted by LeeTee on Stack Overflow See other posts from Stack Overflow or by LeeTee
Published on 2012-05-31T15:51:23Z Indexed on 2012/06/01 10:40 UTC
Read the original article Hit count: 249

Filed under:
|
|
|

I have a PHP script that outputs an array of data. This is then transformed into JSON using the json_encode() function. My issue is I have a date within my array and its is not in the correct javascript format. How can I convert this within PHP so it is?

$newticket['ThreadID'] =  $addticket;
$newticket['Subject'] =  $subject;
//$newticket['DateCreated'] =  date('d-m-Y G:H');

Instead of the above fo rthe date I need the equivilant of the javascript function

new Date()

When I output the above I get the following "Fri Jun 01 2012 11:08:48 GMT+0100 (GMT Daylight Time)" However, If I format my PHP date to be the same, javascript rejects it. Confused...

Can anyone help?

© Stack Overflow or respective owner

Related posts about php

Related posts about JavaScript