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 3 of 3
  1. #1
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,099
    Thanks
    297
    Thanked 12 Times in 12 Posts

    Exclamation pulling date info from db and displaying it frmatted on page?

    Hi All,

    i am pulling out some dates from a db (which is stored as a date field) and am trying to get it to display on the page as e.g December 2008 instead of 2008-12-12.

    i have looked on google and have found out that i need to use F and Y to format the date as i want which is fine, but what im not sure how to do is select the value to be formatted.

    i have
    echo $row['prodRelease'];

    which prints out 2008-12-12 but i am unsure of how to format the date using the F Y???

    any help appreciated

    thanks
    Luke
    Last edited by LJackson; 03-17-2010 at 05:17 PM.

  • #2
    Regular Coder
    Join Date
    Nov 2009
    Location
    Scotland / Glasgow
    Posts
    184
    Thanks
    1
    Thanked 19 Times in 19 Posts
    check out the php manual for date formatting options.

    you will be looking to do something like.

    PHP Code:
    echo date("l d'S F, y"strtotime($row['prodRelease'])); 
    hope it helps
    .:To me AS is like LEGO, Only for the big Kids :.
    - Site - Blog - Glasgow Flasher

  • #3
    Senior Coder
    Join Date
    Jun 2008
    Location
    Cornwall
    Posts
    2,099
    Thanks
    297
    Thanked 12 Times in 12 Posts
    hi mate,

    thanks for your reply,

    i just found out that doing the formatting in the sql query is quicker and easier?

    so i have this
    PHP Code:
    SELECT *, DATE_FORMAT(prodRelease'%e %b %y') AS formatedDate 
    which is currently giving me 14 Dec 09 just need to find the correct format

    EDIT
    ====

    found the solution
    PHP Code:
    DATE_FORMAT(prodRelease'%M %Y'
    does the trick

    thanks mate
    Luke


  •  

    Posting Permissions

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