time of day

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Brian

    #1

    time of day

    I need to print a section of an html page only if the time is after
    5:00am and before 9:00pm local time (Seattle, WA: GMT -0800 during
    standard time, GMT -0700 during daylight savings time). I found a
    bewildering number of functions for getting local or GMT timestamps,
    and formatting them. But I can't find anything that will return the
    time of day. Am I missing something obvious? Or must I put together my
    own function to get time of day?

    --
    Brian (remove ".invalid" to email me)

  • Brian

    #2
    Re: time of day

    Brian wrote:
    [color=blue]
    > I can't find anything that will return the time of day.[/color]

    Naturally, I find gettimeofday() moments after pressing the send
    button. ;-) Still trying to figure this one out, and see if it will
    meet my nees. It returns local time, but the local time of the server
    is not the same as the local time of the client, so it could get dicey.

    --
    Brian (remove ".invalid" to email me)

    Comment

    • Brian

      #3
      Re: time of day

      Brian wrote:
      [color=blue]
      > I need to print a section of an html page only if the time is after
      > 5:00am and before 9:00pm local time (Seattle, WA: GMT -0800 during
      > standard time, GMT -0700 during daylight savings time).[/color]

      I'm trying to put something together, but getting unexpected results.
      Below are script excerpts, followed by the output I see in my browser.
      The local timezone is US edt (GMT -0400). When I ran the script, it
      was Monday, 15:38 (3:38pm). I'm not sure why the hour difference in
      Seattle was off; I was expecting Monday 12:38 (12:38pm).

      <?php
      $local = getdate();
      print "<P>".$loca l[weekday];
      print "<P>".$loca l[hours];
      print "<P>";
      print_r($local) ;
      ?>

      Monday

      15

      Array ( [seconds] => 29 [minutes] => 38 [hours] => 15 [mday] => 26
      [wday] => 1 [mon] => 7 [year] => 2004 [yday] => 207 [weekday] =>
      Monday [month] => July [0] => 1090870709 )

      <?php

      $hoursFromGMT = 8-date(I);
      print "hours from GMT ".$hoursFromGMT ;
      $pacificTimesta mp = (gmmktime() - ($hoursFromGMT* 60*60));

      $seattle = getdate($pacifi cTimestamp);
      print "<P>".$seat tle[weekday];
      print "<P>".$seat tle[hours];
      print "<P>";
      print_r($seattl e);

      ?>

      hours from GMT 7

      Monday

      4

      Array ( [seconds] => 29 [minutes] => 38 [hours] => 4 [mday] => 26
      [wday] => 1 [mon] => 7 [year] => 2004 [yday] => 207 [weekday] =>
      Monday [month] => July [0] => 1090831109 )

      --
      Brian (remove ".invalid" to email me)

      Comment

      Working...