strtotime related question

Discussion in 'PHP' started by afridy, Nov 7, 2012.

  1. #1
    Hai folks,

    strtotime($dt . '- 60 days'));
    PHP:
    in the above it has two parameters or 1?
    bit confused :confused:
     
    afridy, Nov 7, 2012 IP
  2. stephan2307

    stephan2307 Well-Known Member

    Messages:
    1,277
    Likes Received:
    33
    Best Answers:
    7
    Trophy Points:
    150
    #2
    count the brackets ;). also helps to put spaces into things.
    try this one

    
    
    strtotime($dt . ' - 60 days');
    
    
    PHP:
     
    stephan2307, Nov 8, 2012 IP
  3. afridy

    afridy Well-Known Member

    Messages:
    810
    Likes Received:
    116
    Best Answers:
    0
    Trophy Points:
    135
    #3
    Hai dtephn,
    one extra bracket sorry :D
    yes, with and without space both method works!
     
    afridy, Nov 8, 2012 IP
  4. linkodev

    linkodev Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    strtotime('-60 days')
    PHP:
    . should be ok for you. check this http://php.net/manual/en/function.strtotime.php.
     
    linkodev, Nov 8, 2012 IP
  5. afridy

    afridy Well-Known Member

    Messages:
    810
    Likes Received:
    116
    Best Answers:
    0
    Trophy Points:
    135
    #5
    afridy, Nov 8, 2012 IP
  6. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #6
    You would do: strtotime('-60 days', strtotime($dt));

    http://php.net/manual/en/function.strtotime.php

    The second parameter is a timestamp. Also, 2012/10/26 is a poor data format for a date because it is ambiguous between the 1st and the 12th of any month.
     
    jestep, Nov 8, 2012 IP
  7. afridy

    afridy Well-Known Member

    Messages:
    810
    Likes Received:
    116
    Best Answers:
    0
    Trophy Points:
    135
    #7
    i am confused now which one to use. because both methods works :)


    but manual says its ok

    Four digit year, month and day with slashes YY "/" mm "/" dd "2008/6/30", "1978/12/22"
    http://www.php.net/manual/en/datetime.formats.date.php
     
    afridy, Nov 9, 2012 IP