SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    sweden
    Posts
    645
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    How do I make this date thing?

    I just don't get it. A mess for me when making a date thing here.
    I've tried a lot of things, but I think I might be close to a solution here, even though there is something all wrong here.

    I want to print what week it is 70 days earlier than today.
    And it has to be 70 days before, since there are different number of weeks some years.
    This is what I've got so far, but it's not working.

    PHP Code:
    $then now()-70;
    $timestamp  $then;
    $showdate date("W"$timestamp); 

  2. #2
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Give strtotime a chance
    PHP Code:
    $then strtotime("70 days ago");
    echo 
    date("W"$then); 

  3. #3
    rajug.replace('Raju Gautam'); bronze trophy Raju Gautam's Avatar
    Join Date
    Oct 2006
    Location
    Kathmandu, Nepal
    Posts
    4,013
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    See this
    PHP Code:
    echo date('W',strtotime("-70 days")); 
    It will show 17th week of this year 2007

    Do you mean that?
    Mistakes are proof that you are trying.....
    ------------------------------------------------------------------------
    PSD to HTML - SlicingArt.com | Personal Blog | ZCE - PHP 5

  4. #4
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    sweden
    Posts
    645
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    That last thing worked really good.

    Now I want to make a dropdown, so people can pick that week or a week that is earlier. Like a dropdown containing last week and 10 weeks before.
    So I did make some stuff and make their choice as a session. Then it can be remembered while visiting the site.

    I guess my way doing this is way too complicated. There is probably a better way to make this work. But I'm always a newbie I guess...

    This is my way of doing this dropdown, which is not working (of course)

    PHP Code:
    <form name="weekchoice" id="weekchoice" method="post" action="<?php session_register('weekchoice');
            
    $_SESSION['weekchoice'] = $_GET['weekchoice']; ?>">
      <select name="weekchoice">
          <option value="<?php echo $backone?>"<?php if (!(strcmp(1$_GET['weekchoice']))) {echo "SELECTED";} ?>><?php echo $backone?></option>
        <option value="<?php echo $backtwo?>"<?php if (!(strcmp(1$_GET['weekchoice']))) {echo "SELECTED";} ?>><?php echo $backtwo?></option>
            <option value="<?php echo $backthree?>"<?php if (!(strcmp(1$_GET['weekchoice']))) {echo "SELECTED";} ?>><?php echo $backthree?></option>
        <option value="<?php echo $backfour?>"<?php if (!(strcmp(1$_GET['weekchoice']))) {echo "SELECTED";} ?>><?php echo $backfour?></option>
            <option value="<?php echo $backfive?>"<?php if (!(strcmp(1$_GET['weekchoice']))) {echo "SELECTED";} ?>><?php echo $backfive?></option>
        <option value="<?php echo $backsix?>"<?php if (!(strcmp(1$_GET['weekchoice']))) {echo "SELECTED";} ?>><?php echo $backsix?></option>
        <option value="<?php echo $backseven?>"<?php if (!(strcmp(1$_GET['weekchoice']))) {echo "SELECTED";} ?>><?php echo $backseven?></option>
        <option value="<?php echo $backeight?>"<?php if (!(strcmp(1$_GET['weekchoice']))) {echo "SELECTED";} ?>><?php echo $backeight?></option>
            <option value="<?php echo $backnine?>"<?php if (!(strcmp(1$_GET['weekchoice']))) {echo "SELECTED";} ?>><?php echo $backnine?></option>
        <option value="<?php echo $backten?>"<?php if (!(strcmp(1$_GET['weekchoice']))) {echo "SELECTED";} ?>><?php echo $backten?></option>
      </select>
      <br />
      <input type="submit" name="Submit" value="SHOW WEEK" />
    </form>


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
  •