Page 1 of 1
fetching month
Posted: Fri Feb 02, 2007 5:14 am
by itsmani1
2007-03-01T13:15:00 means March 1, 2007 Thursday, 1:15 pm
i am doing
Code: Select all
$date = "2007-03-01T13:15:00";
date("F j, Y<b\\r/>l, g:i a", strtotime(str_replace('T',' ',$date)))
to convert it.
Is there anyway that I can find month from : 2007-03-01T13:15:00
thank you
Posted: Fri Feb 02, 2007 6:30 am
by superdezign
Code: Select all
date("F", mktime(0, 15, 13, 03, 01, 2007));
I may have messed up the mktime() parameter order, but you can always look that up.
Posted: Fri Feb 02, 2007 7:13 am
by itsmani1
like this will return month, date year
is there anything i can pass digit and get the month string and vice versa.
thank you
Posted: Fri Feb 02, 2007 8:38 am
by superdezign
date("F") returns only the month (string/nominal)
date("m") returns only the month (integer)
and you can split() strings to do mktime()
Posted: Fri Feb 02, 2007 11:11 am
by RobertGonzalez
Code: Select all
<?php
$date = "2007-03-01T13:15:00";
// Get the 2 digit numeric of the month
$month = date("m", strtotime(str_replace('T',' ',$date))) ;
// Get the 1 digit numeric of the month (below 10)
$month = date("n", strtotime(str_replace('T',' ',$date))) ;
// Get the short string name of the month
$month = date("M", strtotime(str_replace('T',' ',$date))) ;
// Get the long string name of the month
$month = date("F", strtotime(str_replace('T',' ',$date))) ;
?>