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 4 of 4
  1. #1
    Regular Coder mOrloff's Avatar
    Join Date
    Nov 2008
    Location
    The Great Pacific NW, USA
    Posts
    424
    Thanks
    8
    Thanked 6 Times in 6 Posts

    Which function should I be using to extract the time I want ??

    I have a dateTime value like 2010-10-09 18:30:54.
    And I want to print it as 6:30:54.

    Nothing I've tried is getting me there, and I've worked myself into so many circles that I'm kinda lost.

    Please point me in the right direction.

    ~ Mo
    Last edited by mOrloff; 11-07-2010 at 05:02 AM.

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,546
    Thanks
    45
    Thanked 259 Times in 256 Posts
    http://php.net/manual/en/function.date.php

    If you have the datetime already, use strtotime, basically doing this

    PHP Code:
    echo date('g:i:s'strtotime($currentDateTime)); 

  • #3
    Regular Coder mOrloff's Avatar
    Join Date
    Nov 2008
    Location
    The Great Pacific NW, USA
    Posts
    424
    Thanks
    8
    Thanked 6 Times in 6 Posts
    Ooooohh!
    strtotime!

    Ugh. I didn't even think to go back to square one... Unformat it into a unix timestamp, then reformat the components I need out of it.

    Thanks. That helps tremendously.
    ~ Mo

  • #4
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,546
    Thanks
    45
    Thanked 259 Times in 256 Posts
    Yup, sometimes that's what it takes... take the specific format, transform to a universal format, then respecify.


  •  

    Posting Permissions

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