search
Homephp教程php手册Commonly used time functions in php

Test environment: php5.3.29

unix timestamp (number of seconds from the Unix epoch (January 1 1970 00:00:00 GMT) to a given time.). Hereinafter referred to as timestamp.


Returns the timestamp of a certain time.

time();

//Get the timestamp of the current local time.


mktime(hour, minute, second, month, day, year);

//It can be omitted from right to left, and the omitted parameters are replaced with the local time. For example, if the last day and year are omitted, the current time of 22nd 2016 will be used.

//You can write two or four digits for the year. When using two digits, 0-69 corresponds to 2000-2069, and 70-100 corresponds to 1970-2000. The four-digit time test is valid from 1970 to 2037.


date('Y-m-d H:i', $time);

//Get the timestamp of parameter 2 and obtain the string in the format of parameter 1. This is my most commonly used format: 2016-08-22 09:02

//Parameter 1 supports many letter values, such as: s (seconds with leading zeros), M (month with three-letter abbreviation), y (two-digit year), T (time zone where the machine is located) ) Wait and check in the manual.


getdate($timestamp);

//Return a unix timestamp as an array, the default value is the current local time, the return value format is as follows

Array
(
    [seconds] => 40
    [minutes] => 58
    [hours]   => 9//24小时制的9点
    [mday]    => 22//日期
    [wday]    => 6//礼拜6
    [mon]     => 10//十月
    [year]    => 2016
    [yday]    => 295//今年的第295天
    [weekday] => Saturday//礼拜6
    [month]   => October//十月
    [0]       => 1055901520//时间戳
)

Uh-huh. These are the ones I commonly use.

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)