Here is a quick and dirty way to see if the “MP” part of your LAMP or WIMP solution is ready for the DST time change. I tested all the production systems here today, and they seem to be working just fine. Here is what you do.
First let’s test MySQL:
SELECT UNIX_TIMESTAMP('2007-03-11 02:00:00')=UNIX_TIMESTAMP('2007-03-11 03:00:00');
The two timestamps should be identical, because of the DST change. So this query should return 1 (one, uno, jeden). If you get anything else, your MySQL is b0rked and you need to patch it.
Same method can be applied for PHP. Paste this code in somewhere and then look at the page:
<?php echo mktime(2, 0, 0, 3, 11, 2007) == mktime(3, 0, 0, 3, 11, 2007); ?>
If you get 1, you are good. Anything else, and you are in a need of a patch.
Note, by default both MySQL and PHP will grab the time from OS so unless you specifically messed with their configuration to change this, chances are you will be just fine. Still, it’s always good idea to check.
[tags]dst, mysql, php, daylight saving time, time change, timestamp[/tags]
For those interested, I wrote a script to update the zoneinfo files on Solaris and Linux:
#!/bin/sh
####################################
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/#
#_/ _/#
#_/ Zoneinfo Update Script _/#
#_/ Written by Craig A. Betts _/#
#_/ January 31, 2007 _/#
#_/ _/#
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/#
####################################
###########
# ABOUT #
###########
# This script will partially automate the process
# of rebuilding the timezone files for UNIX.
#############
# CHANGES #
#############
##############
# SETTINGS #
##############
# Get Host Type
hosttype=`uname -s`
# Location of the untarred tzdata file from ftp://elsie.nci.nih.gov/pub
tzsource=/tmp/junk
# Timestamp for backups
timestamp=`date '+%Y%m%d%H%M%S'`
# Some commands are in different places on different OSes.
# We will set the default here for now.
zic=/usr/sbin/zic
##########
# MAIN #
##########
case $hosttype in
SunOS)
ziloc=/usr/share/lib/zoneinfo
;;
Linux)
ziloc=/usr/share/zoneinfo
;;
*)
echo "I do not know how to update systems of type $hosttype"
exit 1
;;
esac
# Make a backup!
cp -R $ziloc $ziloc.bak-$timestamp
# Rebuild the database!
for zone in africa antarctica asia australasia etcetera \
europe factory northamerica solar87 solar88 solar89 \
southamerica systemv backward
do
echo "$zic -v $tzsource/$zone"
$zic -v $tzsource/$zone
done
grab the latest definition from ftp://elsie.nci.nih.gov/pub and place it in /tmp/junk. The script will do the rest.
Luke- got a way to fix that error in my typing on that script?
Oh man… It went into moderation queue and then WordPress totally barfed when I approved it. But it seems that it did go through.