Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Converting Time in PHP

    I have an application that gives me numbers like 1183354915 and the php coding converts it into a time.

    print date('d m Y', $row['topic_time']);


    Are there any converters that will allow me to input July 2, 10:59PM and it will spit out that number?

    Thank You,
    Brad C
    www.clicknowdomains.com

  • #2
    Regular Coder Iszak's Avatar
    Join Date
    Jun 2007
    Location
    Perth, Western Australia
    Posts
    332
    Thanks
    2
    Thanked 58 Times in 57 Posts
    Yes, you can! I would suggest reading the manual first.. but I mean there are so
    many functions so I don't blame you.. anyhow this is how to do it..

    PHP Code:
    <?php
    $string 
    "July 2, 10:59PM";
    echo 
    strtotime($string);
    ?>
    OR...

    PHP Code:
    <?php
    echo strtotime("July 2, 10:59PM");
    ?>
    and forgot output.. this is what it'll output "1183417140"

    Enjoy!
    Last edited by Iszak; 07-02-2007 at 12:02 PM. Reason: Forgot Output!

  • #3
    New to the CF scene
    Join Date
    Nov 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    All this does it provides the output of "-1" Am I missing something?

    Thank You,
    Brad

  • #4
    Regular Coder Iszak's Avatar
    Join Date
    Jun 2007
    Location
    Perth, Western Australia
    Posts
    332
    Thanks
    2
    Thanked 58 Times in 57 Posts
    You must be, because it outputs exactly as I put it in both examples.

  • #5
    New Coder
    Join Date
    Jan 2006
    Location
    UK (Britain)
    Posts
    29
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just so you no, there is another function quite useful in generating time stamps:

    mktime();

    Look it up on php.net


  •  

    Posting Permissions

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