DST Readines Test for MySQL and PHP

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.

Related Posts:

  • PHP4 Mail Function: Sent Time is 1 Hour Ahead
  • MySQL Performance Tips
  • Dump MySQL table into CSV file
  • MINUS query in MySQL
  • MySQL: How to get the key of last inerted row in PHP
  • MySQL Admin 1.0.19: libmysqlx.dll Error
  • Dreamhost Outage
  • MySQL no Longer Provides Free Binaries
  • Project Idea
  • Geek Test

  • 3 Responses to “DST Readines Test for MySQL and PHP”

    1. Gravatar Craig Betts UNITED STATES Says: Reply to this comment

      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.

      Posted using Mozilla Firefox Mozilla Firefox 2.0.0.2 on Solaris Solaris
    2. Gravatar Craig Betts UNITED STATES Says: Reply to this comment

      Luke- got a way to fix that error in my typing on that script?

      Posted using Mozilla Firefox Mozilla Firefox 2.0.0.2 on Solaris Solaris
    3. Gravatar Luke UNITED STATES Says: Reply to this comment

      Oh man… It went into moderation queue and then Wordpress totally barfed when I approved it. But it seems that it did go through.

      Posted using Mozilla Firefox Mozilla Firefox 2.0.0.2 on Ubuntu Linux Ubuntu Linux

    Leave a Reply

    XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <pre lang=""> <em> <i> <strike> <strong>

    [Quote selected]