Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Day of the week finder

jandrewsjandrews Posts: 30Member
I'm creating an online calendar for my faculty at my high school to use, but in order to properly display a given month, I need to know on what day of the week the first of the month falls. How do I query what day of the week a given date falls on? Thanks.

James

Comments

  • tvientitvienti Posts: 230Member
    Use the strtotime and date functions. I'm not sure if that's the most efficient way, but it would work.

    strtotime let's to turn a string into a time represented as number of seconds since a fixed point. date accepts a number of seconds since the fixed point, and turns it into a string formatted however you want, according to the formatting string you input. So:

    [code]
    $seconds = strtotime('1 December, 2006');
    $day = date('l', $seconds);
    [/code]

    That will get you the day (Sunday - Saturday) that falls on the date 12/1/2006.

    T

    : I'm creating an online calendar for my faculty at my high school to use, but in order to properly display a given month, I need to know on what day of the week the first of the month falls. How do I query what day of the week a given date falls on? Thanks.
    :
    : James
    :

  • mac_doggiemac_doggie Posts: 488Member
    [b][red]This message was edited by mac_doggie at 2006-1-4 3:14:50[/red][/b][hr]
    or:
    [code]
    // mktime parameters:
    // hours, minutes, secods (don't need them so make them 0
    // then month, day, year
    // date("w") returns the day of the week 0 - 6 (0 beng sunday)
    $dayofweek = date("w", mktime(0,0,0,12,1,2006));

    [/code]

    also see: http://nl2.php.net/manual/en/function.date.php
    and: http://nl2.php.net/manual/en/function.mktime.php


    : Use the strtotime and date functions. I'm not sure if that's the most efficient way, but it would work.
    :
    : strtotime let's to turn a string into a time represented as number of seconds since a fixed point. date accepts a number of seconds since the fixed point, and turns it into a string formatted however you want, according to the formatting string you input. So:
    :
    : [code]
    : $seconds = strtotime('1 December, 2006');
    : $day = date('l', $seconds);
    : [/code]
    :
    : That will get you the day (Sunday - Saturday) that falls on the date 12/1/2006.
    :
    : T
    :
    : : I'm creating an online calendar for my faculty at my high school to use, but in order to properly display a given month, I need to know on what day of the week the first of the month falls. How do I query what day of the week a given date falls on? Thanks.
    : :
    : : James
    : :
    :
    :

    ;-)
    -mac-
    mailto:mac_doggie@hotmail.com
    the Netherlands...




Sign In or Register to comment.