How to format the date in PHP and how to convert the PHP time format?

Updated on number 2024-05-06
4 answers
  1. Anonymous users2024-02-09

    The date(format,time) function has 2 parameters to format the output of the date, the first format is the format you want to be in the form y m d is the month, day and year, like h:i:s is the hour:

    Minutes: seconds, the upper and lower case of the first letter represents different time systems, there are 12 hours and 24 hours. The second parameter time is the time that needs to be formatted, which is the current time by default, or it may be the past time or future time that you save in the database.

    For more specific instructions, see the date function of the library for more details. The strtotime() function converts the time of the text into a timestamp. How to use it?

    The second argument of the date() function is a timestamp, which means that the time you want to output and save in the database may be a text string, which needs to be converted to a timestamp by the strtotime() function and sent to the date() function for formatting output. The standard instance is date("d js f y ",strtotime($dateposted))。

    dateposted is a text time that I save in the database. In this way, the form can be perfectly output.

  2. Anonymous users2024-02-08

    date('y-m-d'This is the date of acquisition.

    time() to get the timestamp.

    strtotime This is converted to a timestamp.

    The specific how to use the manual can be found.

  3. Anonymous users2024-02-07

    strtotime

    date has a lot of functions about time.

    Search for it.

  4. Anonymous users2024-02-06

    php Date Format Conversion Summary:

    Convert the current time to yyyy-mm-dd format string, and then convert it to date format, which goes around in a circle.

    echo strtotime(date('y-m-d',time())' 00:00:00');

    Converts characters in the GNU date input format to time.

    echo strtotime('now');

    Standard strings are converted to time.

    t = '2012-9-10 15:18:06';

    time = strtotime($t);

    Convert time to date character yyyymmdd and then to integer format.

    d = intval(date('ymd',$time));

    header("content-type: text/html; charset=utf-8");

    txdate = '2016-06-16';

    datetime1 = strtotime($txdate);int 1466028000 parses the English text datetime to a UNIX timestamp:

    datetime2= date("y-m-d h:i:s",$datetime1); //string '2016-06-16 00:00:00'

    length=19) date() function formatting the timestamp to a more readable date and time.

    Splicing today's last time 2016-06-16 23:59:59

    datetime= date("y-m-d h:i:s",strtotime(date("y-m-d",strtotime($datetime2)).

    23 hours 59 minutes 59 seconds "));//string '2016-06-16 23:59:59' (length=19)

    sql = select * form `vvt_user` where userid = 100 and date_time >= $datetime2 and date_time <= $datetime;?>

Related questions
13 answers2024-05-06

1.In the power-off state, press and hold the phone's power button, volume +, and volume at the same time. >>>More

6 answers2024-05-06

Before reinstalling the system, it is best to format it once, you can use the hard disk tool with PE and other software to format, you can also enter PE my computer to click on the C disk or other disks, right-click menu formatting for formatting, if you do not change the system, you can only format other disks other than the system, you can also right-click, you can also enter management, disk management, and then formatting, but formatting must ensure that the things on the disk are useless, once formatted, you can't find it back.

21 answers2024-05-06

The new disk must be formatted before it can be used, otherwise it cannot be used. The hard drive has been formatted by the manufacturer before it leaves the factory. Before the floppy disk leaves the factory, some manufacturers have formatted it, and some manufacturers have not. >>>More

14 answers2024-05-06

You said how to format Wang Wei's mobile phone if you forgot the password, you first have to go to the China Mobile I ordered the mobile phone you bought, where to go to the mobile phone store to refresh your mobile phone, and then log in again, but it is equivalent to formatting, there is nothing, just like a new machine. Buy back the same, what you want for yourself**.

2 answers2024-05-06

Quickly format the USB flash drive first, and select "EXFAT" in the "File System" before formatting"Format (as shown in the figure below, select EXFAT for formatting), then the U disk capacity is restored, and select the "file system" format you need again to format it again, and it's OK, remind you, all files are deleted after formatting. >>>More