Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP Date Format

Options
  • 27-06-2005 3: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 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