How to format date variable

Hi, I am stumped by one small problem. I have a routine which gets data from a DB and displays it.
It works very well, apart from how the date is displayed. I have tried several possible ways of formatting the date but it always comes out in the SQL format: 2025-10-5 for example. Here’s a bit of what I have:

while ($row = $res->fetch_assoc()){
	$nicedate = date('m-d-Y',strtotime($row['talkdate']));	
		?>
		<h2><?php echo $nicedate; ?>: <?php echo($row['talktitle']); ?> </h2>

Everything works properly - apart from how the date is displayed. I know that ‘m-d-Y’ isnt how I want the string to look (I just did it like that so I could see a difference between what I want and what I get), I just don’t want it to be ‘2025-10-5’!
(some of the above is coming out in a bold font by the way)

To post code on the forum, either put bbcode [code][/code] tags or markdown three back-ticks ``` on their own lines, above and below your code. I have edited your post above.

Your posted code works for me and outputs an expected - 10-05-2025: some title

Ah, the variable to be formatted is ‘talkdate’. ‘talktitle’ comes out as it should (i.e., the value of the ‘talktitle’ variable).
Just checked what you said and… thanks again! I played about with the date format and it now comes out as it should (Sunday 5 October 2025)
I feel like sending you a xmas card! :grin:

Sponsor our Newsletter | Privacy Policy | Terms of Service