Example _php instance of PHP timestamp conversion

Source: Internet
Author: User

The following example shows the result:

Copy Code code as follows:

Array (3) {[' Yesterday ']=> Array (2) {[0]=> int (1395874800) [1]=> int (1395961199)} [' Today ']=> Array (2) {[0] => Int (1395961200) [1]=> int (1396047599)} ["Tomorrow"]=> Array (2) {[0]=> int (1396047600) [1]=> Int (13961 33999)}}

Copy Code code as follows:

<?php

Yesterday, today and tomorrow's date conversion
($startstr start time stamp today)
Return (Yesterday, today and tomorrow) 0 points and 23 points 59 minutes 59 seconds
function Alldaytostr ($STARTSTR) {
$oneday _count = 3600 * 24; How many seconds in a day
Tomorrow
$tomorrow _s = $startstr + $oneday _count; Start from tomorrow
$tomorrow _e = $tomorrow _s + $oneday _count-1; It ends tomorrow.
Yesterday
$yesterday _s = $startstr-$oneday _count; Started yesterday
$yesterday _e = $startstr-1; Ended yesterday
It's over today.
$today _e = $tomorrow _s-1;
Yesterday, today and tomorrow 0 and 23, 59 minutes, 59 seconds, combine the groups.
$allday _array = Array (' Yesterday ' => array ($yesterday _s, $yesterday _e),
' Today ' => Array ($startstr, $today _e),
' Tomorrow ' => Array ($tomorrow _s, $tomorrow _e));
return $allday _array;
}
Day start time
$btime = Date (' y-m-d '. ') 00:00:00 ', Time ());
Time stamp converted to start
$btimestr = Strtotime ($btime);
Var_dump (Alldaytostr ($BTIMESTR));

?>

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.