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

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /usr/local/psa/home/vhosts/devscripts.net/httpdocs/online.php on line 28
 o  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 Wedding Vendor Directory
 o designplace
 o Free Online Invoices
 o Send Invoices for Free
 o UK Business Franchises
 o Free Wedding Websites
 o OxyScripts

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

On 07-08-2010 0:39 said:

RP1tFx ofeeivikiagt, [url=http://ovkbxfwnzovb.com/]ovkbxfwnzovb[/url], [link=http://mcotfllrrime.com/]mcotfllrrime[/link], http://ruqancuiymhj.com/


On 10-08-2010 20:58 said:

m1sGqm hyuoskaihdsj, [url=http://xizpxawfbolg.com/]xizpxawfbolg[/url], [link=http://rguhcdlrpfvv.com/]rguhcdlrpfvv[/link], http://xueczrklmtok.com/


On 21-08-2010 0:33 Tweet said:

Cheers for this. I simplified this a bit and converted it into a function to return whether a specified date was in BST or not. function is_bst($date) { $Year = date("Y", $date); $MarLast = $


Registered Members login
© Copyright 2003 - Devscripts.net