date_create

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

    #1

    date_create

    I'm porting some perl (a calendar) over to php and I have some date
    questions.

    What I'd like to do is feed in a month and year and get the number of
    days in the month and the starting day of the week.

    The date function does this:

    $day_of_week = date('w',$unix_ timestamp);
    $days_in_month = date('t',$unix_ timestamp);

    Now, I don't know how to get the timestamp easily.

    I thought I could do this:

    $date_obj = date_create();
    date_date_set($ date_obj,$year, $month,1);

    But I don't know how to get the timestamp out of the date_obj. What's
    the function for that?

    Is there an easier way to do this?

    Perl is a bit erratic in how it indexes months and years. I didn't see
    much in the docs but:

    Is the month "1" indexed (ie, January is 1)?
    Is the day also 1 index?
    Is the year a 4 digit year?

    That would be sensible which is not the case in Perl!

    Jeff
  • Geoff Berrow

    #2
    Re: date_create

    Message-ID: <Q8Wdnd8W-L4lbXPVnZ2dnUVZ _uGdnZ2d@earthl ink.comfrom Jeff
    contained the following:
    >The date function does this:
    >
    > $day_of_week = date('w',$unix_ timestamp);
    > $days_in_month = date('t',$unix_ timestamp);
    >
    Now, I don't know how to get the timestamp easily.

    --
    Geoff Berrow 011000100110110 0010000000110
    001101101011011 001000110111101 100111001011
    100110001101101 111001011100111 010101101011
    http://slipperyhill.co.uk - http://4theweb.co.uk

    Comment

    Working...