HOw to check if day is Saturday?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • laredotornado@zipmail.com

    HOw to check if day is Saturday?

    Hi,

    I'm using PHP 4.4.4 and I was wondering if anyone knows of a function
    or quick way, given a scalar representation of month (as a number
    between 1 and 12), day, and year (as a four digit number, e.g. 2007),
    how would I tell if that day is a Saturday?

    Thanks, - Dave

  • Chuck Anderson

    #2
    Re: How to check if day is Saturday?

    laredotornado@z ipmail.com wrote:
    Hi,
    >
    I'm using PHP 4.4.4 and I was wondering if anyone knows of a function
    or quick way, given a scalar representation of month (as a number
    between 1 and 12), day, and year (as a four digit number, e.g. 2007),
    how would I tell if that day is a Saturday?
    >
    Thanks, - Dave
    >
    >
    Use mktime() with your month day and year as inputs to create a timestamp.
    e.g., $tstamp = mktime(0, 0, 0, $month, $day, $year);
    .... and then use:
    date('l', $tstamp); to get the textual representation of the day of the
    week
    (or use 'N' to get 1 - 7, 6 being Saturday)

    --
    *************** **************
    Chuck Anderson • Boulder, CO

    *************** **************

    Comment

    • Geoff Berrow

      #3
      Re: HOw to check if day is Saturday?

      Message-ID: <1164585815.753 718.159260@l12g 2000cwl.googleg roups.comfrom
      laredotornado@z ipmail.com contained the following:
      >I'm using PHP 4.4.4 and I was wondering if anyone knows of a function
      >or quick way, given a scalar representation of month (as a number
      >between 1 and 12), day, and year (as a four digit number, e.g. 2007),
      >how would I tell if that day is a Saturday?
      Check out date() and mktime()

      --
      Geoff Berrow (put thecat out to email)
      It's only Usenet, no one dies.
      My opinions, not the committee's, mine.
      Simple RFDs http://www.ckdog.co.uk/rfdmaker/

      Comment

      • Curtis

        #4
        Re: HOw to check if day is Saturday?

        laredotornado@z ipmail.com wrote:
        Hi,
        >
        I'm using PHP 4.4.4 and I was wondering if anyone knows of a function
        or quick way, given a scalar representation of month (as a number
        between 1 and 12), day, and year (as a four digit number, e.g. 2007),
        how would I tell if that day is a Saturday?
        >
        Thanks, - Dave
        Or, you could try using strtotime to get the timestamp:

        <?php
        # if the month, day, and year aren't already in a single scalar, put
        them in one
        $date = "${month}/${day}/${year}";

        $dayOfWeek = date('l', strtotime($date ));
        ?>

        Comment

        Working...