Get the current time in the format of year-month-day hour:minute:second ."/> Get the current time in the format of year-month-day hour:minute:second .">

Home>Article>Backend Development> How to get the current time in php

How to get the current time in php

(*-*)浩
(*-*)浩 Original
2019-09-20 11:29:32 11427browse

The Date/Time function allows you to get the date and time from the server the PHP script is running on. You can use the Date/Time functions to format dates and times in different ways.

How to get the current time in php

#Note:These functions depend on the local settings of the server. Remember to take daylight saving time and leap years into account when using these functions.

PHP Date/Time functions are an integral part of PHP core. No installation is required to use these functions. (Recommended learning:PHP programming from entry to proficiency)

Get the current date and time through the date() function in PHP

date(string format,int timestamp)

The date() function will return a string generated by the timestamp parameter according to the specified format. The timestamp parameter is optional. If omitted, the current time will be used. The format parameter can be the date and time output in the format specified by the developer.

"; echo "当前的日期为:".date("Y-m-d",mktime())."

"; echo "当前的时间为:".date("H:i:s",mktime()); ?>

Use function date() to realize

Display format: year-month-day hour: minute: second

The above is the detailed content of How to get the current time in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:php get file size Next article:php get file size