The JSON spec allows integers, fractional numbers, strings, arrays, but when it comes to dates things are handled differently. There really is no date format in the JSON spec. Would be nice if every JSON date output would conform to ISO8601 :)
// Ruby 2011-07-14 19:43:37 +0100 //ISO 8601 2011-07-14T19:43:37+0100 // Javascript Date Object // Javascript built-in JSON object 2012-04-23T18:25:43.511Z // .NET JavaScriptSerializer // .NET DataContractJsonSerializer
Some of these can easily be converted to a PHP timestamp using strtotime(), others require some more magic.
Here is a way to transform the .NET variant, something that has been haunting me in a current project ;)
$dt = new DateTime('@' . $match[1]); $dt = new DateTime($dt->format('Y-m-d H:i:s') . ' ' . $match[2]);
Due to the wide usage of JSON as an exchange format, I really hope we will see a spec update in the future :)
What are particle animations? Particle network animations in JavaScript typically involve creating visual representations of… Read More
BOOKING SOLUTIONS 202x This is my take on a subset of booking, appointment, PMS or… Read More
THE GOAL Create a system cron for WordPress, that is accessible and can be easily… Read More
2024, what's cooking? Slowly getting into the 2024 spirit. 3 projects coming to a close… Read More
Short look back at 2023 This has been a busy and interesting year. I am… Read More
Elementor Pro provides grid containers as an experimental feature. The options provided are limited, when… Read More