Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Member
    Join Date
    May 2005
    Location
    Rochester, NY
    Posts
    83
    Member #
    10054
    This is definitely a newbie question...The date field in my MySQL database uses a Unix timestamp that looks like this: 2005-08-16 12:34:15 but when I print it out in HTML, I want it to say August 16, 2005. I tried using the date function like so:
    Code:
    <? echo date("F j Y", $row["post_date"]); ?>
    But that must not be kosher because all I get is December 31 1969. I've looked at the manual at php.net but I obviously am not understanding something because it looks simple enough. I pass date() the format I want and the value I want formatted. The format is printed correctly, the problem is it's not the date from my database.
    Any help would be appreciated.
    Thanks,
    Mike
    michael murphy
    Professional Web Development
    http://www.letsgomurphys.com/

  2.  

  3. #2
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    Try this:
    PHP Code:
    $tstamp=$row["post_date"];

        
    $yearsubstr($tstamp,0,4);
        
    $monsubstr($tstamp,5,2);
        
    $daysubstr($tstamp,8,2);

        print 
    date("F j Y "mktime(000$mon$day$year)); 
    S. Rosland

  4. #3
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    Or even easier:
    PHP Code:
    print date("F j Y"strtotime($row["post_date"])); 
    S. Rosland

  5. #4
    Member
    Join Date
    May 2005
    Location
    Rochester, NY
    Posts
    83
    Member #
    10054
    Thanks Rosland, I appreciate it. The second, simpler code works like a charm.
    -Mike
    michael murphy
    Professional Web Development
    http://www.letsgomurphys.com/


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 09:12 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com