Date and time in 24 hours format

前端 未结 2 373
悲&欢浪女
悲&欢浪女 2021-01-04 01:52

I have a date in this format Fri, 15 Jan 2016 15:14:10 +0800, and I want to display time like this 2016-01-15 15:14:10.

What I tried is:

2条回答
  •  感动是毒
    2021-01-04 02:22

    https://www.w3schools.com/php/php_date.asp

    Get a Date

    The required format parameter of the date() function specifies how to format the date (or time).

    Here are some characters that are commonly used for dates:

    • d - Represents the day of the month (01 to 31)
    • m - Represents a month (01 to 12)
    • Y - Represents a year (in four digits)
    • l (lowercase 'L') - Represents the day of the week

    Get a Time

    Here are some characters that are commonly used for times:

    • H - 24-hour format of an hour (00 to 23)
    • h - 12-hour format of an hour with leading zeros (01 to 12)
    • i - Minutes with leading zeros (00 to 59)
    • s - Seconds with leading zeros (00 to 59)
    • a - Lowercase Ante meridiem and Post meridiem (am or pm)

    https://www.php.net/manual/en/datetime.format.php

    public DateTime::format ( string $format ) : string
    

    format( 'Y-m-d H:i:s' );
    

提交回复
热议问题