date('Y-m-d H:i:s',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");
?>
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~