PHP mktime() 函数
定义和用法
mktime() 函数返回一个日期的 Unix 时间戳。
参数总是表示 GMT 日期,因此 is_dst 对结果没有影响。
参数可以从右到左依次空着,空着的参数会被设为相应的当前 GMT 值。
语法mktime(hour,minute,second,month,day,year,is_dst)
hour | 可选。规定小时。 |
minute | 可选。规定分钟。 |
second | 可选。规定秒。 |
month | 可选。规定用数字表示的月。 |
day | 可选。规定天。 |
year | 可选。规定年。在某些系统上,合法值介于 1901 - 2038 之间。不过在 PHP 5 中已经不存在这个限制了。 |
is_dst | 可选。如果时间在日光节约时间(DST)期间,则设置为1,否则设置为0,若未知,则设置为-1。 自 5.1.0 起,is_dst 参数被废弃。因此应该使用新的时区处理特性。 |
提示和注释
注释:在 PHP 5.1 之前,如果该函数的参数非法,则会返回 false。
例子
mktime() 函数对于日期运算和验证非常有用。它可以自动校正越界的输入:
<?phpecho(date("M-d-Y",mktime(0,0,0,12,36,2001)));echo(date("M-d-Y",mktime(0,0,0,14,1,2001)));echo(date("M-d-Y",mktime(0,0,0,1,1,2001)));echo(date("M-d-Y",mktime(0,0,0,1,1,99)));?>
输出:
Jan-05-2002Feb-01-2002Jan-01-2001Jan-01-1999

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

11 Best PHP URL Shortener Scripts (Free and Premium)

Working with Flash Session Data in Laravel

Build a React App With a Laravel Back End: Part 2, React

Simplified HTTP Response Mocking in Laravel Tests

cURL in PHP: How to Use the PHP cURL Extension in REST APIs

12 Best PHP Chat Scripts on CodeCanyon

Announcement of 2025 PHP Situation Survey
