Home > Backend Development > PHP Tutorial > Introduction to date() function in PHP

Introduction to date() function in PHP

小云云
Release: 2023-03-22 11:14:01
Original
1432 people have browsed it

Date means date. This article mainly shares with you an introduction to the date() function in PHP. It mainly shares with you a small piece of code. I hope it can help you.

<?php
// 设置时区
date_default_timezone_set("PRC");
 
// 打印当前时间  PHP_EOL 换行符,兼容不同系统
echo date("Y-m-d H:i:s")  . PHP_EOL;
echo date("Y 年 m 月 d 日 H 点 i 分 s 秒")  . PHP_EOL;
// 指定时间
$time = strtotime("2018-01-18 08:08:08");  // 将指定日期转成时间戳 
echo date("Y-m-d H:i:s", $time)  . PHP_EOL;
?>
Copy after login

Related recommendations:

Detailed explanation of the date() function in PHP

Detailed explanation of the new date() parameter in js

How to solve the browser compatibility problem of Date() date function in js

The above is the detailed content of Introduction to date() function in PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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