Get month of a given date which is stored in a PHP time variable in 'Y-m-d' format
+2
A:
$parts = explode('-',$your_date_variable_in_php);
$month = $parts[1];
ShiVik
2010-08-13 06:13:44
I prefer this one.
Col. Shrapnel
2010-08-13 06:18:41
+3
A:
$date = "2010-08-12";
$d = date_parse_from_format("Y-m-d", $date);
echo $d["month"];
Bill Karwin
2010-08-13 06:15:21
+3
A:
http://php.net/manual/en/function.date.php
use this link . I think your problem is solved for any date format.
ritesh choudhary
2010-08-13 06:15:28
A:
You can use date() and strtotime():
<?php
$date = "2010-08-13";
echo date("m",strtotime($date))."\n";
?>
vtorhonen
2010-08-13 06:15:34
A:
is it really stored in PHP? Not in some database?
month(datefield) can do it in mysql query for example
Col. Shrapnel
2010-08-13 06:17:44