The time format obtained from an API is 2014-10-30T15: 59: 59.999ZPHP. How to format it as a normal date, for example, Y-m-dH: I: the time format obtained by s from an API is as follows:
2014-10-30T15:59:59.999Z
PHP how to format it as a normal date, for example
Y-m-d H:i:s
Reply content:
The time format obtained from an API is as follows:2014-10-30T15:59:59.999Z
PHP how to format it as a normal date, for exampleY-m-d H:i:s
You can define it by yourself. Now we use the object-oriented method to operate the time, which is the so-called DateTime.
There are many defined formats
DateTime implements DateTimeInterface {/* constant */const string ATOM = "Y-m-d \ TH: I: sP"; const string COOKIE = "l, d-M-Y H: i: s T "; const string ISO8601 =" Y-m-d \ TH: I: sO "; const string RFC822 =" D, d M y H: I: s O "; const string RFC850 =" l, d-M-y H: I: s T "; const string RFC1036 =" D, d M y H: I: s O "; const string RFC1123 =" D, d m y h: I: s O "; const string RFC2822 =" D, d m y h: I: s O "; const string RFC3339 = "Y-m-d \ TH: I: sP"; const string RSS = "D, d m y h: I: s O "; const string W3C = "Y-m-d \ TH: I: sP ";...... // Http://php.net/manual/zh/class.datetime.php}
The preceding format is as follows:
$date = new DateTime('2014-10-30T15:59:59.999Z');echo $date->format('Y-m-d H:i:s');
Echo (date_format (date_create ('2017-10-30T15: 59: 59.999z'), 'y/m/d H: I: s '));
Such a standard ISO time format
Why is no one replying to the abnormal and common strtotime function?