Free web development scripts for the webmasterDevelopment Scripts

 Site Navigation
 o Development Scripts
 o Text Only Edition
 o PHP.net News
 o Tutorials
 o Register an account
 o New entries this week
 o Affiliates/Links
 o Contact Us
 o About us
 o Advanced Search

 Browse Path
 o 5 users online
 o Most users online: 67
 o Home
  o PHP
   o Miscellaneous
    o Script

 Member Login
User Name
Password

 Standards
Valid XHTML 1.0!
Valid 
CSS!

 Recommended Links
 o PHP Freaks
 o Designer Baby Clothes
 o Advertise Here Make Money
 o devnet
 o OxyScripts
 o Open Source Design
 o Free Wedding Websites
 o Wedding Vendor Directory
 o designplace

British Summer Time? (BST) (Rated 4)

Description:

This PHP function will let you know if we are currently in British Summer Time.

Sounds useless doesn't it. Trust me, it has some uses. For example some British hosting companies keep their servers set to GMT and do not adjust for BST. The reason being is that it would be unfair on their international clients. Fair enough.

The European Union has now adopted The Ninth European Parliament and Council Directive on Summer Time Arrangements in which it states that British Summer (or daylight saving) time will be kept between the last Sunday in March to the last Sunday in October. The changes will take place at 1am GMT.

Code starts here


<?
// declare some start variables
$ThisYear = (date("Y"));
$MarStartDate = ($ThisYear."-03-25");
$OctStartDate = ($ThisYear."-10-25");
$MarEndDate = ($ThisYear."-03-31");
$OctEndDate = ($ThisYear."-10-31");

//work out the Unix timestamp for 1:00am GMT on the last Sunday of March, when BST starts
while ($MarStartDate <= $MarEndDate)
{
$day = date("l", strtotime($MarStartDate));
if (
$day == "Sunday"){
$BSTStartDate = ($MarStartDate);
}
$MarStartDate++;
}
$BSTStartDate = (date("U", strtotime($BSTStartDate))+(60*60));
echo
"BST this year starts at 1:00am GMT on ";
echo
date("l, dS M", $BSTStartDate);
echo
"<br>";

//work out the Unix timestamp for 1:00am GMT on the last Sunday of October, when BST ends
while ($OctStartDate <= $OctEndDate)
{
$day = date("l", strtotime($OctStartDate));
if (
$day == "Sunday"){
$BSTEndDate = ($OctStartDate);
}
$OctStartDate++;
}
$BSTEndDate = (date("U", strtotime($BSTEndDate))+(60*60));
echo
"BST this year ends at 1:00am GMT on ";
echo
date("l, dS M", $BSTEndDate);
echo
"<br>";

//Check to see if we are now in BST
$now = mktime();
if ((
$now >= $BSTStartDate) && ($now <= $BSTEndDate)){
echo
"We are now in BST";
}
else {
echo
"We are now in GMT";
}

?>


Submitted by Devscripts on 07-04-2004 9:38


Rate This Script

User Contributed Comments

Registered Members login
© Copyright 2003 - Devscripts.net