1

How do I convert PHP DateTime object to Javascript Date object ?

new Date('06/18/2016') in Javascript = Date {Sat Jun 18 2016 00:00:00 GMT+0800 (SE Asia Standard Time)}

It's easy to get month, just mydate.getMonth() but it didn't work when I try to convert date from PHP

new DateTime('06/18/2016') in PHP = Object { date="2016-06-18 00:00:00", timezone_type=3, timezone="Asia/Kuala_Lumpur"} using mydate.getMonth() didn't work.

jasonlam604
  • 1,456
  • 2
  • 16
  • 25
  • If you mean [this object](http://php.net/manual/en/class.datetime.php), it has [`getTimestamp`](http://php.net/manual/en/datetime.gettimestamp.php) method returning a timestamp which can be easily converted to JS timestamp by appending 3 zeroes. – hindmost Jun 22 '16 at 08:15
  • Possible duplicate of [Convert PHP date into javascript date format](http://stackoverflow.com/questions/10837022/convert-php-date-into-javascript-date-format) – Rajesh Jun 22 '16 at 08:15

0 Answers0