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 6 of 6
  1. #1
    Regular Coder
    Join Date
    Mar 2006
    Posts
    478
    Thanks
    3
    Thanked 0 Times in 0 Posts

    convert datestamp from one to another?

    i have stored the date in the following format...

    2008-01-07 15:42:00

    it is year,day,month, hour,min,sec

    and wish to convert it to the format needed for RSS feeds.

    "D, d M Y H:i:s GMT"

    how can i do this please.

    thanks

  • #2
    Regular Coder mlse's Avatar
    Join Date
    Mar 2005
    Posts
    624
    Thanks
    20
    Thanked 19 Times in 18 Posts
    This should work (untested!):

    PHP Code:
    $original_date "2008-01-07 15:42:00";
    $reformatted_date date("D, d M Y H:i:s \G\M\T"strtotime($original_date)); 
    Might come out with 7th Jan rather than 1st July though ...
    Last edited by mlse; 01-07-2008 at 04:10 PM.

  • #3
    Regular Coder
    Join Date
    Mar 2006
    Posts
    478
    Thanks
    3
    Thanked 0 Times in 0 Posts
    i have PHP version 4.3.11

    is there another way?

  • #4
    Regular Coder mlse's Avatar
    Join Date
    Mar 2005
    Posts
    624
    Thanks
    20
    Thanked 19 Times in 18 Posts
    Both date() and strtotime() are present in all versions of PHP4

    Opps! Just noticed you'd replied to the original version of my message! Lol! Yep, the edited one should work - but watch the d/m thing m/d thing
    Last edited by mlse; 01-07-2008 at 04:14 PM. Reason: Noticed reply above!

  • #5
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,044
    Thanks
    2
    Thanked 316 Times in 308 Posts
    Where do you have it stored in that format?

    Edit: And do you truely want that to be - year,day,month or do you want it to be year,month,day?
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #6
    Regular Coder mlse's Avatar
    Join Date
    Mar 2005
    Posts
    624
    Thanks
    20
    Thanked 19 Times in 18 Posts
    Indeed, if it's in a MySQL database you can use the DATE_FORMAT function.


  •  

    Posting Permissions

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