Pete Winter
asked on
date format
I am printing dates from a database as below:
$row_rs_tax_diary['date']
Currently this prints as the following date format:
11/03/19 - i.e. Year, Month, Date
I would like it to be converted to print as
Sat 19th March
How can I do this?
$row_rs_tax_diary['date']
Currently this prints as the following date format:
11/03/19 - i.e. Year, Month, Date
I would like it to be converted to print as
Sat 19th March
How can I do this?
try like this,
$date = $row_rs_tax_diary['date'];
$formatted = date('M. d, Y', strtotime($date));
$date = $row_rs_tax_diary['date'];
$formatted = date('M. d, Y', strtotime($date));
ASKER
logudotcom - Thanks but the result was incorrect.
The result was
Nov. 03, 2019
I want it to be
Sat 19th March
The result was
Nov. 03, 2019
I want it to be
Sat 19th March
try this,
<?php
$date = '11/03/19';//$row_rs_tax_diary['date']
$formatted = date('D jS F', strtotime($date));
// Sat 19th March
echo $formatted;
?>
i think you need pass the correct date format ...so that it displays well
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Use this string instead of:
$row_rs_tax_diary['date'] - this must be a timestamp
date("D jS F",$row_rs_tax_diary['date ']);
$row_rs_tax_diary['date'] - this must be a timestamp
date("D jS F",$row_rs_tax_diary['date
you need to pass the year as "yyyy-mm-dd" ... you will get exact result
ASKER
logudotcom - Thanks, but the result of $row_rs_tax_diary['date'] is 11/03/19 not 2011/03/19 as you have used. This makes the result Sun 3rd November not Sat 19th March.
How can I fix this?
How can I fix this?
since this is the 21 century and will be for a long time, do something like this:
$new_date="20"+$row_rs_tax _diary['da te'];
then you will have the format used by log
$new_date="20"+$row_rs_tax
then you will have the format used by log
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
andreizz - Thanks I understand this the simplest solution and will not cause a problem for 89 years which I'm sure will be more than enough for my website life time, but if we were going to do this without any possible future bugs how would li be done?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Many thanks all.
21st Century here we come!!! :)
21st Century here we come!!! :)
ASKER
or should I say 22nd Century here we come! :)
http://php.net/manual/es/function.date.php