Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

PHP Date Format

  • 27-06-2005 03:00PM
    #1
    Closed Accounts Posts: 334 ✭✭


    Hi all,

    any idea of how to convert a date in the format of 2005-06-10 to June 10th 2005?
    If I use the date function $StartDate= date("F j, Y"); It gives me todays date, which is not what I want, I want to convert a date in the past.

    Cheers.


Comments

  • Registered Users, Registered Users 2 Posts: 1,393 ✭✭✭Inspector Gadget


    PHP's date() function takes an optional second parameter, which is your time in the form of a unix timestamp (i.e. the no. of seconds since midnight on Jan 1 1970...). There are other functions (such as mktime()) you can use to make suitable timestamps to stick in there.

    This is real RTFM stuff, to be honest...
    Gadget


  • Closed Accounts Posts: 334 ✭✭WhatsGoingOn


    PHP's date() function takes an optional second parameter, which is your time in the form of a unix timestamp (i.e. the no. of seconds since midnight on Jan 1 1970...). There are other functions (such as mktime()) you can use to make suitable timestamps to stick in there.

    This is real RTFM stuff, to be honest...
    Gadget

    Cheers Inspector, I managed to get it sorted

    $StartDate= (date("j M Y", strtotime($StartDate)));


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    Use the date function with a datestamp seeded using the mktime function.


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    This is real RTFM stuff, to be honest...
    True.


Advertisement