My input date 2014-03-10 05:40:00. How to convert it to RFC format, for example 2014-3-10T05:40:00.000-00:00?
2014-03-10 05:40:00
2014-3-10T05:40:00.000-00:00
here in php5 added another option similar to this
$datetime= date("c", strtotime("2014-03-10 05:40:00")); echo $datetime; //Output : 2014-03-10T05:40:00+00:00
RFC3339 is one of the predefined class format constantsDateTime .
DateTime
$inputDate = "2014-03-10 05:40:00"; $datetime = \DateTime::createFromFormat("Y-m-d H:i:s", $inputDate); echo $datetime->format(\DateTime::RFC3339);
I would like to add that predefined constants for this can also be used with date(). Both:
date()
date(DATE_RFC3339);
and
date(DATE_ATOM);
returns an RFC3339 formatting date date string and is equivalent to:
date('Y-m-d\TH:i:sP');
Source: https://habr.com/ru/post/1530947/More articles:Reading an elliptic curve private key from a file using BouncyCastle - javaWhat does a step in OpenGL meanHow to load an assembly dynamically using Assembly.Load on a Windows 8 phone? - c #filter column with list in angular ngtable - javascriptChecking table compatibility in sqlalchemy - pythonиспользовать pingdom для мониторинга мыльного обслуживания - soapProperty Priority: system file and descriptor file versus properties file - javaHandling link outlines in JSON.net - jsonWindows Phone 8 => Download DLL at runtime? - c #QML Javascript "console.log" with UTF-8 - javascriptAll Articles