note 93239 modified in function.jdtojewish by danbrown
| From: | danbrown@php.net | Date: | Sun, 30 Aug 2009 18:57:48 +0000 |
| Subject: | note 93239 modified in function.jdtojewish by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-160059@lists.php.net to get a copy of this message | ||
Sometimes it is useful to have the date in the format YYYY-MM-DD, which is sortable (e.g. you can
sort dates by sorting the strings):
<?php
function JDToSortableJewish($jd) {
return
preg_replace("|(\d+)/(\d+)/(\d+)|","$3-$1-$2", // year-month-day
preg_replace("|/(\d)/|","/0$1/", // add zeros to the day
preg_replace("|^(\d)/|","0$1/", // add zeros to the month
JDToJewish($jd))));
}
?>
--was--
Sometimes it is useful to have the date in the format YYYY-MM-DD, which is sortable (e.g. you can
sort dates by sorting the strings):
function JDToSortableJewish($jd) {
return
preg_replace("|(\d+)/(\d+)/(\d+)|","$3-$1-$2", // year-month-day
preg_replace("|/(\d)/|","/0$1/", // add zeros to the day
preg_replace("|^(\d)/|","0$1/", // add zeros to the month
JDToJewish($jd))));
}
http://php.net/manual/en/function.jdtojewish.php