fightbulc / moment.php

Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js
Other
973 stars 154 forks source link

Incorrect timezone parsing W3C + DTS #187

Open GrupoWebex opened 5 years ago

GrupoWebex commented 5 years ago

moment js example format output: 2019-10-27T00:00:00+02:00

I send on post to php: $test = new \Moment\Moment('2019-10-27T00:00:00+02:00'); print_r($test); echo $test->format(); $test2 = $test->cloning()->addDays(1); echo $test2->format();

invalid output =========== Moment\Moment Object ( [rawDateTimeString:Moment\Moment:private] => 2019-10-27T00:00:00+02:00 [timezoneString:Moment\Moment:private] => Europe/Madrid [immutableMode:Moment\Moment:private] => [date] => 2019-10-27 00:00:00.000000 [timezone_type] => 1 [timezone] => +02:00 ) 2019-10-27T00:00:00+0200 2019-10-28T00:00:00+0200

============================================ Then i go default params on main function: $test = new \Moment\Moment('2019-10-27T00:00:00','Europe/Madrid'); print_r($test); echo $test->format(); $test2 = $test->cloning()->addDays(1); echo $test2->format();

valid output =========== Moment\Moment Object ( [rawDateTimeString:Moment\Moment:private] => 2019-10-27T00:00:00 [timezoneString:Moment\Moment:private] => Europe/Madrid [immutableMode:Moment\Moment:private] => [date] => 2019-10-27 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Madrid ) 2019-10-27T00:00:00+0200 2019-10-28T00:00:00+0100

There is some way to do it compatible with default momentjs output? (YYYY-MM-DDTHH:mm:ssZZ)

Thanks for support