--- Marian Briones <[EMAIL PROTECTED]> wrote:

> Anyway, I have this one site that has a countdown to their next 
> event on it.  I forgot to go in and change it to standard time 
> when we switched to standard time in October.
> 
> Is there a nifty way I can script it to know when we make our 
> time changes during the year?  I'm not sure how PHP handles 
> things like "the third Sunday in October"
> 
> I look forward to finding out!!!!
> 
> Marian


Since PHP looks at the server time, I guess you are saying that you did not 
have your clock
automatically adjust itself with a time server.  You may want to look into this 
since PCs are
notorious for keeping time poorly.  

The network time protocol servers use ntpd and you should be able to correct 
your time on a
regular basis with a cron job.

If you want to generate the "third Sunday in October" you can do something like 
this with
strtotime().  

$ cal 10 2006
    October 2006
Su Mo Tu We Th Fr Sa
 1  2  3  4  5  6  7
 8  9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31

$ cat daylight.php
<?php

  print date("D m/d/Y", strtotime("Third Sunday October 2006")) . "\n\n";

?>

$ php daylight.php
Mon 10/23/2006


However, I note that the result is one greater (Monday the 23rd instead of 
Sunday the 22nd) than
it should be:

$ cat daylight.php
<?php

  print date("D m/d/Y", strtotime("Third Sunday October 2006 -1 day")) . "\n\n";

?>

$ php daylight.php 2>/dev/null
Sun 10/22/2006

James
_____

James D. Keeline
http://www.Keeline.com  http://www.Keeline.com/articles
http://Stratemeyer.org  http://www.Keeline.com/TSCollection

http://www.ITeachPHP.com -- Free Computer Classes: Linux, PHP, etc.
Fall Semester Begins Sep 7 -- New Classes Start Every Few Weeks.
Spring Semester Begins in late January.  Two new class topics.


Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to