Query-thinkphp of Time function

Source: Internet
Author: User

1.question: The default date Korean bundle produces time and time difference eight hours, time zone default setting is not Beijing time

Date_default_timezone_set (' PRC '); China time Zone
$test = Date ("Y-m-d h:i:s", Time ());

The difference between timestamp and datetime in a 2.mysql time field

3. Time format

Function Description Strtotime: Time conversion to timestamp detail is

Echo strtotime (Date (' y-m-d ')); rs-"1429372800

Queries for 4.MySQL databases

The current time $test = Date ("y-m-d h:i:s", Times ());

Day Query $start = date ("Y-m-d", Time ()). ' 00:00:00 ';//start of the day

$end = Date ("Y-m-d", Time ()). ' 23:59:59 ';//The End of the day

Month to current time query

$start =strtotime (Date (' y-m-01 00:00:00 '));
$end = strtotime (Date (' y-m-d h:i:s '));
$data [' CID ']= $cid;
$data [' createtime '] = Array (' Between ', Array ($start, $end));

An entire month of inquiries

$test = Date ("Y-m-01 h:i:s", Time ());//The first day of the month

$test = Date ("Y-m-t 23:59:59", Time ());//Last Day of the month

Forward backwards * * * Month * * Query

$test = 6;
$PD =date (' y-m-d h:i:s ', Strtotime ('-'. $test. ' Day '));
$PD 1=date (' y-m-d h:i:s ', Strtotime (' 2 Day '));
echo "Tomorrow:", Date (' y-m-d h:i:s ', Strtotime ('-'. $test. ' Day '));

Query-thinkphp of Time function

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.