Whether the specified time is in the daylight saving time system

Source: Internet
Author: User
Tags time and seconds
How to determine whether the specified time is a daylight saving time? how to determine whether to use the U.S. daylight saving time?

I know that I can write a function to determine whether it is currently in the U.S. summer order...

But I can't tell you how to judge it at the specified time ....


// Xia Ling system judgment
Function is_dst (){
$ Timezone = date ('e'); // Obtain the current time zone
Date_default_timezone_set ('US/Pacific-new'); // force the time zone
$ Dst = date ('I'); // when determining whether to renew
Date_default_timezone_set ($ timezone); // restore the time zone
Return $ dst; // return the result

}


Reply to discussion (solution)

Isn't the second parameter of date used to specify the time?

The second parameter does not seem to work...

$ LastUpdateint = 13819522810;

Echo date ("I", lastUpdateint );
The returned result is 0 ....

I don't know if my understanding of the timer is incorrect. it's just a human setting.

The timestamp is the number of seconds from January 1, 1970 to a certain time point. different countries may have different local time in different time periods.

But how can you conclude that the time and seconds are obtained from the United States in the hour?


If I do not understand the error, it is impossible for you to implement this requirement.

* USA DST
* From 2: 00 AM at the second week of March To 2: 00 AM at the first weeek of November
This is the start time and end time of the U.S. period ~

You need to maintain a list if the region is used ~

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.