PHP Timestamp Conversion Example _php Tutorial

Source: Internet
Author: User
The following examples draw the result:
Copy CodeThe code is 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 the Code code as follows:

Yesterday, today and tomorrow's date conversion
($startstr start timestamp 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 a day
Tomorrow
$tomorrow _s = $startstr + $oneday _count; Start from tomorrow
$tomorrow _e = $tomorrow _s + $oneday _count-1; Tomorrow is over.
Yesterday
$yesterday _s = $startstr-$oneday _count; Started yesterday
$yesterday _e = $startstr-1; Ended yesterday
Ends today
$today _e = $tomorrow _s-1;
Yesterday, today and tomorrow 0 points and the same day 23 points 59 minutes 59 seconds Combined Array
$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 ());
Timestamp converted to "start"
$btimestr = Strtotime ($btime);
Var_dump (Alldaytostr ($BTIMESTR));

?>

http://www.bkjia.com/PHPjc/747676.html www.bkjia.com true http://www.bkjia.com/PHPjc/747676.html techarticle The following example shows the result: the copy code code is as follows: Array (3) {["Yesterday"]= Array (2) {[0]= int (1395874800) [1]= Int (1395961199)} ["Today"]= array (2) {[0]= int (1395961200) [...]

  • 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.