Date Change

I have a row in my database called createdate. Its set at TIMESTAMP CURRENT TIMESTAMP

When i echo this i have used this

echo "" .$row["createdate"].  "<br><br>";

This shows as 2023-04-08 19:20:43

I want this to show Saturday 8th April 2023 19:20

How do i change the format ?

Thanks

See the MySql date_format() function - https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_date-format

echo date("l jS F Y H:i", strtotime($row["createdate"])) . "<br><br>";

Thank you i did try several options. I can see where i went wrong. I did research this a lot but never got it right.
I appreciate your help.

This is the absolute correct answer. I would like to add some information based on the documentation so it is clear what the code is doing.

In this example, date() is called with a format string that specifies the order and format of the different components of the timestamp:

  • l represents the full name of the day of the week (e.g., “Saturday”)
  • jS represents the day of the month, with an ordinal suffix (e.g., “8th”)
  • F represents the full name of the month (e.g., “April”)
  • Y represents the full year (e.g., “2023”)
  • H:i represents the hour and minute in 24-hour format (e.g., “19:20”)

The strtotime() function is used to convert the timestamp string to a Unix timestamp that date() can format.

Note that the format string is case-sensitive, so you should use uppercase and lowercase letters as shown in the example. Also, make sure that the timezone settings are correct, as this can affect the output of the date() function.

Sponsor our Newsletter | Privacy Policy | Terms of Service