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

Thread: date issues...

  1. #1
    New to the CF scene
    Join Date
    May 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    date issues...

    hi folks,

    I have a small issue with some coding work, and wonder if someone could shed some light on for me please..

    PHP Code:
    print "<td>"date('d-m-y',$row['fldEndDate']) ."</td>"
    the date within the database is this: 2009-04-30 00:00:00
    however - on the output I'd like it to show 30-04-2009

    it's currently displaying the 01-01-70

    Could anyone aid my blindness here....!?! lol
    Last edited by TheGreenWelly; 05-09-2009 at 11:23 PM. Reason: changed to resolved

  • #2
    Regular Coder sea4me's Avatar
    Join Date
    Jan 2009
    Location
    Damn, I don't know...
    Posts
    390
    Thanks
    11
    Thanked 28 Times in 27 Posts
    use explode....

    if u want i can show u an example...

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    date expects an integer value representing a timestamp. You can convert it prior to querying (tounixtime(), something like that), or you can use php's strtotime to convert that as well. This would work only in PHP5+
    MySQL will let you format you're date differently as well. Check this link out for info on that: http://dev.mysql.com/doc/refman/5.1/...on_date-format

    Oh btw, my recommendation is to do it from the PHP side of things. MySQL does make it easier, but I like the control that my application provides for me when it comes to formatting.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #4
    New to the CF scene
    Join Date
    May 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Cheers folks!

    new code now
    PHP Code:
     date('d-m-y',strtotime($row['fldEndDate'])) 
    thanks to @jasonatennui on twitter too.

    Thanks again


  •  

    Tags for this Thread

    Posting Permissions

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