I have never seen this time format. How to format it in PHP?

Source: Internet
Author: User
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?


  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.