PHP gets the timestamp of today's start and end

Source: Internet
Author: User

Example

$t = time ();

Start time stamp

$start = Mktime (0,0,0,date ("M", $t), date ("D", $t), date ("Y", $t));

End time stamp

$end = Mktime (23,59,59,date ("M", $t), date ("D", $t), date ("Y", $t));
The definition and specific usage of the Mktime function record

Grammar

Mktime (HOUR,MINUTE,SECOND,MONTH,DAY,YEAR,IS_DST)

example today, yesterday, last week, this month's start time stamp and end time stamp

Start time cut
$start =mktime (0,0,0,date ("M"), Date ("D"), Date ("Y"));
End time Truncation:
$end =mktime (0,0,0,date (' m '), date (' d ') +1,date (' Y '))-1;
PHP gets yesterday's start timestamp and end time stamp
$beginYesterday =mktime (0,0,0,date (' m '), date (' d ') -1,date (' Y '));
$endYesterday =mktime (0,0,0,date (' m '), date (' d '), date (' Y '))-1;
PHP gets last week's start time stamp and end timestamp
$beginLastweek =mktime (0,0,0,date (' m '), date (' d ')-date (' W ') +1-7,date (' Y '));
$endLastweek =mktime (23,59,59,date (' m '), date (' d ')-date (' W ') +7-7,date (' Y '));
PHP gets this month's start timestamp and end time stamp
$beginThismonth =mktime (0,0,0,date (' m '), 1,date (' Y '));
$endThismonth =mktime (23,59,59,date (' m '), date (' t '), date (' Y '));

Definitions and usage

The Mktime () function returns a Unix timestamp for a date.

The parameter always represents the GMT date, so IS_DST has no effect on the result.

The parameters can be left-to-right, and the empty arguments will be set to the appropriate current GMT value.

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.