PHP gets the current date and formats it, php gets the current date_PHP tutorial

WBOY
Release: 2016-07-13 10:20:22
Original
802 people have browsed it

PHP gets the current date and formats it, php gets the current date

date('Y-m-d H:i:s',time());
Copy after login

How does PHP get the current time

To set the time zone, PHP's default time zone is not China's time zone, but Greenwich Mean Time. So just set the time zone and you’re done! date_default_timezone_set('Etc/GMT-8'); //The time zone is set here
echo date("Y-m-d H:i:s");
?>

How to get the timestamp (year-month-day) of the current date in PHP?

Just use the date function to format it!
echo date("Y-m-d",time());
See the picture for format string description~
I hope my answer will be helpful to you! Haha~


PHP gets the current date and formats it, php gets the current date_PHP tutorial

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/867007.htmlTechArticlePHP gets the current date and formatting, php gets the current date date('Y-m-d H:i:s',time ()); How to get the current time in PHP requires setting the time zone. The default PHP time zone is not China’s time zone, but Greenwich Mean Time...
Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!