PHP timestamp problems with a few small examples

Source: Internet
Author: User
Tags echo date

<?php

Header ("Content-type:text/html;charset=utf-8");

Set Beijing time as the default time zone
Date_default_timezone_set (' PRC ');

Output Current Time

echo Date ("Y-m-d h:i:s", Time ()); 2018-01-30 10:30:32

Get a time stamp for the wee hours of the day

$today = Strtotime (Date ("y-m-d"), Time ());

Echo ' <br> ';

Echo $today; 1470844800

Echo ' <br> ';

Verify that the time stamp is correct early in the day

echo Date ("Y-m-d h:i:s", $today); 2016-08-11 00:00:00

Echo ' <br> ';

24-point timestamp of the day

$end = $today +6024;

Verify that the 24-point timestamp is correct on the day

echo Date ("Y-m-d h:i:s", $end); 2018-01-30 00:00:00

Echo ' <br> ';

Gets the timestamp of 0 points at the specified time

$time = Strtotime (' 2018-01-30 ');

Echo ' <br> ';

Echo $time; 1401984000

Echo ' <br> ';
Verifies whether the timestamp is a specified time
echo Date ("Y-m-d h:i:s", $time); 2018-01-30 00:00:00

?>

PHP timestamp problems with a few small examples

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.