Date Convert
Posted: Thu Jul 27, 2006 4:10 pm
anyone know how to convert a unix style 07,08 date to english like jan, feb, mar?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
<?php
/**********************************************************
* Days of the Week array
*********************************************************/
$days_array = array(
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
);
/**********************************************************
* Develop an array of months
*********************************************************/
$months_array = array(
1 => 'January',
2 => 'February',
3 => 'March',
4 => 'April',
5 => 'May',
6 => 'June',
7 => 'July',
8 => 'August',
9 => 'September',
10 => 'October',
11 => 'November',
12 => 'December');
?>Code: Select all
<?php
echo date("F", time());
?>You can if you just insert the month into a date field, like this:Everah wrote:Lets say all you know about the selected month is that it is month number 8. What PHP function tells you the name of the month? date() does not do that.
Code: Select all
$m="08";
$d="2000-$m-04";
echo date("F", strtotime($d));Code: Select all
function getMonthAsString($month)
{
$unix_timestamp = mktime(null, null, null, trim($month, '0') + 1, null, null);
return date("F", $unix_timestamp);
}