note 118365 added to functions.user-defined
| From: | MuneebAslam | Date: | Mon, 23 Nov 2015 15:09:14 +0000 |
| Subject: | note 118365 added to functions.user-defined | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-204212@lists.php.net to get a copy of this message | ||
following is a function that can be used to convert numeric date to alphabetic date, e-g from
2015-11-16 to 16 Nov, 2015.
1. Function takes 3 parameters, numeric date, locale and length of month
2. Function currently supports EN and ES month names.
3. Function can be calles as <?php
convertDate("2015-11-16","en","full"); ?>
<?php
function convertDate($date,$locale,$length){
$monthNames = array(
"en" => array(
"full" =>
array(1=>'January','February','March','April','May',
'June','July','August','September','October','November','December'),
"short" =>
array(1=>'Jan','Feb','Mar','Apr','May','Jun',
'Jul','Aug','Sep','Oct','Nov','Dec')
),
"es" => array(
"full" =>
array(1=>'Enero','Febrero','Marzo','Abril','Mayo',
'Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Deciembre'),
"short" =>
array(1=>'Ene','Feb','Mar','Abr','May','Jun',
'Jul','Ago','Sep','Oct','Nov','Dec')
),
);
$exploded = explode("-",$date);
$year = $exploded[0];
$month = $exploded[1];
$day = $exploded[2];
$month = $monthNames[$locale][$length][$month];
$date = $day . " " . $month . ", " . $year;
return $date;
}
?>
----
Server IP: 72.52.91.14
Probable Submitter: 90.170.124.223
----
Manual Page -- http://php.net/manual/en/functions.user-defined.php
Edit -- https://master.php.net/note/edit/118365
Del: integrated -- https://master.php.net/note/delete/118365/integrated
Del: useless -- https://master.php.net/note/delete/118365/useless
Del: bad code -- https://master.php.net/note/delete/118365/bad+code
Del: spam -- https://master.php.net/note/delete/118365/spam
Del: non-english -- https://master.php.net/note/delete/118365/non-english
Del: in docs -- https://master.php.net/note/delete/118365/in+docs
Del: other reasons-- https://master.php.net/note/delete/118365
Reject -- https://master.php.net/note/reject/118365
Search -- https://master.php.net/manage/user-notes.php