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
    Join Date
    Nov 2002
    Location
    Carmel California
    Posts
    471
    Thanks
    0
    Thanked 1 Time in 1 Post

    date formating question

    Hi, I am wondering how I would convert a date from the format of
    2004-03-21 00:00:00 into 3/21/04 I am not to great in php so I dont know how to do this in php.
    Kris Hubby
    kwhubby site

  • #2
    Regular Coder
    Join Date
    Mar 2004
    Posts
    115
    Thanks
    0
    Thanked 0 Times in 0 Posts
    $string="2004-03-21 00:00";

    $date=date("m/d/y",strtotime($string));
    echo $date;

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Location
    Carmel California
    Posts
    471
    Thanks
    0
    Thanked 1 Time in 1 Post
    Great thanks
    Kris Hubby
    kwhubby site

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Brisbane, Australia
    Posts
    181
    Thanks
    1
    Thanked 0 Times in 0 Posts

    UNIX Timestamps

    For everyone who reads this thread, I would like to stress emphasis on Unix Timestamps.

    What is a unix timestamp?
    A unix timestamp is a number that calculates the date relative to the epoch (the 1/1/1970, i think, either that or '75). It tells the computer how many seconds since the epoch you are talking about in time.

    An Example?

    Code:
    THIS:    SELECT Now()
    RETURNS: 22-03-2004
    
    THIS:    SELECT UNIX_TIMESTAMP()
    RETURNS: 1079936537
    
    THIS:    SELECT UNIX_TIMESTAMP(Now())
    RETURNS: 1079936537
    From what we see here, we're selecting the time from SQL (alternatively, you can get the time from the function: time())

    The difference is that because the first two are in Unix Timestamp format, you can pass them through the date() function in PHP to show the kind of date that you want.

    Despite the name
    Despite the name, yes you can use Unix Timestamps on Windows servers.
    -mR_eGo
    _______________________
    Programming since
    3 years old.


  •  

    Posting Permissions

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