SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    nyc
    Posts
    223
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    to what week belongs a date?...

    Hi all

    I must compare a date generated with:
    $date1 = date('y-m-d');
    and a date generated with:
    $date2 = date('W');

    ($date2 outputs "35" for example, as the 35th week of the year)

    How can I convert a date in the format 'y-m-d' into a date in the format 'W', so I can determine if it belongs to the same week?

    I can't find the solution... Can anybody help?

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Whistler, Canada
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    // this week
    $thisweek date("W");

    // the date you generated
    $date '07-06-01';

    // get unix timestamp for generated date
    $date_timestamp mktime($date);

    // use timestamp to get week number for that date
    $date_week date("W"$date_timestamp);

    if(
    $date_week == $thisweek) {
        
    // do your stuff

    Hope this helps

    Cheers,
    Pepe


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •