PHP date formatting

I want to convert the date from this format: 01/07/09to this jan 07,09.

How can I do this in PHP?

+5
source share
3 answers

Use strptimeto analyze the resulting value, then dateto display it in the desired format:

echo date("M d,y", strptime("01/07/09", "d/m/y"));

If you are running Windows or using a version of PHP where it is strptimenot available (<PHP 5.1.0), use strtotime, but be careful that your date is in US English (that is, "01/07/09" means January 7, 2009 years, not July 1, 2009).

, jan, jan, strtolower:

echo strtolower(date("M d,y", strptime("01/07/09", "d/m/y"));
+7

, , .

<?php echo date('M d, y', strtotime('01/07/09'));?>
+8

Just pass the date variable to strtotime. See the PHP manual for more details .

$date = "01/07/09";
echo date("M d,y", strtotime($date));   
+2
source

All Articles