note 57605 added to function.date
| From: | DueJogn at Gmail dot com | Date: | Sat, 08 Oct 2005 11:44:12 +0000 |
| Subject: | note 57605 added to function.date | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-96667@lists.php.net to get a copy of this message | ||
<?php
/*
a simple date function witch turns an english date syntax into a hebrew syntax something like this:
Before:Saturday 08th of October 2005 15:26
After:יום שבת ה08
לאוקטובר 2005 15:26
*/
function date2heb()
{
$eng_date = date("l dS \of F Y H:i");#getting date with syntax: Saturday 08th of October
2005 15:01
$eng_date_array = explode(" ",$eng_date);#arraying the date for a cormftuble use
#Renaming the date array
$eng_date_array['week_day'] = $eng_date_array[0]; unset($eng_date_array[0]);
$eng_date_array['num'] = $eng_date_array[1]; unset($eng_date_array[1]);
$eng_date_array['of'] = $eng_date_array[2]; unset($eng_date_array[2]);
$eng_date_array['month'] = $eng_date_array[3]; unset($eng_date_array[3]);
$eng_date_array['year'] = $eng_date_array[4]; unset($eng_date_array[4]);
$eng_date_array['time'] = $eng_date_array[5]; unset($eng_date_array[5]);
#loading the names of the motnth and dayes into an array
$heb_date_array_db = array(
'month' => array(
'January' => "ינואר" ,
'February' =>
"פברואר",
'March' => "מרס",
'April' => "אפריל",
'May' => "מאי",
'June' => "יוני",
'July' => "יולי",
'August' =>
"אוגוסט",
'September' =>
"ספטמבר",
'October' =>
"אוקטובר",
'November' =>
"נובמבר",
'December' => "דצמבר",
),
'week_day' => array(
'Sunday' => "ראשון",
'Monday' => "שני",
'Tuesday' => "שלישי",
'Wednesday' => "רבעי",
'Thursday' => "חמישי",
'Friday' => "שישי",
'Saturday' => "שבת",
),
);
#replacing with hebrew
foreach($heb_date_array_db['week_day'] as $eng_week_day => $heb_week_day)
if($eng_week_day == $eng_date_array['week_day'])
$heb_date_array['week_day'] = "יום " .
$heb_week_day . " ";
$heb_date_array['num'] =
str_replace("th","",$eng_date_array['num']);
$heb_date_array['num'] = "ה" . $heb_date_array['num'] .
" ";
$heb_date_array['of'] = "ל";
foreach($heb_date_array_db['month'] as $eng_month => $heb_month)
if($eng_month == $eng_date_array['month'])
$heb_date_array['month'] = $heb_month . " ";
$heb_date_array['year'] = $eng_date_array['year'] . " ";
$heb_date_array['time'] = $eng_date_array['time'] . " ";
$heb_date = implode("",$heb_date_array);#having the date imploded
return $heb_date;
#cheers! leon
}
echo date2heb();
?>
----
Manual Page -- http://www.php.net/manual/en/function.date.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+57605
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57605&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57605&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57605&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57605&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57605&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57605&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57605&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+57605&report=yes
Search -- http://master.php.net/manage/user-notes.php