Results 1 to 3 of 3

Thread: strtotime("now") question

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2007
    Location
    Hong Kong
    Posts
    384

    strtotime("now") question

    the following program shows that strtotime("now") doesn't give out the second of yyyy-mm-dd hh:mm:ss format.
    PHP Code:
    <?
    $strstart = strtotime("2008-08-11 01:21:41");
    $strend = strtotime("2008-08-11 02:03:41");//please change the time to current time
    $now = strtotime("now");
    echo '$strstart: '.$strstart."<br/>";
    echo '$strend: '.$strend."<br/>";
    echo '$now: '.$now."<br/>";

    echo '$strend-$strstart: ';echo $strend-$strstart."<br/>";
    echo '$strstart-$strend: ';echo $strstart-$strend."<br/>";
    echo '$strstart-$now: ';echo $strstart-$now."<br/>";
    echo '$now-$strstart: ';echo $now-$strstart."<br/>";
    echo "end-start minute:";echo ($strend-$strstart)/60;
    echo "<br/>now-start minute:";echo ($now-$strstart)/60;
    ?>
    Result:
    $strstart: 1218417701
    $strend: 1218420221
    $now: 1218391429
    $strend-$strstart: 2520
    $strstart-$strend: -2520
    $strstart-$now: 26272
    $now-$strstart: -26272
    end-start minute:42
    now-start minute:-437.866666667

    my expected result is want to see $strend-$strstart: 2520 and 42 minute.

  2. #2
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: strtotime("now") question

    it does show 42 minutes. Divide the result by 60.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2007
    Location
    Hong Kong
    Posts
    384

    Re: strtotime("now") question

    ah..sorry, I forgot to give my situation..
    Now, I save "2008-08-11 01:21:41" into a column which type is date.
    "select regdate from member"
    I will get the $starttime = "2008-08-11 01:21:41"...Then I will use strtotime("now") to get the second of current time, such as $now = "2008-08-11 02:21:41"..
    then $now-$starttime = 3600..But I meet the problem at the first post

Posting Permissions

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



Click Here to Expand Forum to Full Width