Date and Time function library: mktime

Source: Internet
Author: User
Keywords PHP Chinese function Handbook date and time function library
Tags aliyun date date and time function library echo example function function library html

Mktime

(PHP3, PHP4)

Mktime---&http://www.aliyun.com/zixun/aggregation/37954.html ">nbsp; Unix time stamp with date acquired

Syntax: int mktime (int hour, int minute, int second, int month, int day, int [, int is_dst])

Description:

Warning: The order of this function parameter differs from the order of the parameters in the normal Unix mktime (), and does not provide a left-to-right omitted argument, which is a common error in the program.

The given parameter returns the UNIX timestamp, which is a total number of seconds between the Unux period (whose 1 1970) and the specified time, and the time stamp returned is a long integer.

Parameters can be omitted from the right to left order, and any argument omitted in this manner will be set to the current value according to the local date and time.

The IS_DST can be set to 1 if the time is the entire period in DST (daylight savings time), or 0 if not, or 1 (preset) If you do not know if you are in the range of DST (daylight savings times).

Note: IS_DST is added to 3.0.10.

Mktime () is useful for calculating and confirming dates, and it automatically calculates the correct values, for example: The following lines will produce a string "jan-01-1998".

Example:

<?php

echo Date ("M-d-y", Mktime (0,0,0,12,32,1997));

echo Date ("M-d-y", Mktime (0,0,0,13,1,1997));

echo Date ("M-d-y", Mktime (0,0,0,1,1,1998));

echo Date ("M-d-y", Mktime (0,0,0,1,1,98));

?>

Year can be a value of two or four digits, and the range of values is 0-69, 2000-2069, and 70-99, 1970-1999.

The final day of next month can be expressed as "0" by any given month, and the following examples will produce a string "The Last Days in modified is:29".

Example:

<?php

$lastday = Mktime (0,0,0,3,0,2000);

Echo strftime ("Last Day in Modified:%d", $lastday);

$lastday = Mktime (0,0,0,4,-31,2000);

Echo strftime ("Last Day in Modified:%d", $lastday);

?>

Reference: Date () time ()

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.