note 90138 added to function.gregoriantojd
| From: | jfg at osu1 dot php dot net | Date: | Tue, 07 Apr 2009 20:19:25 +0000 |
| Subject: | note 90138 added to function.gregoriantojd | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-152926@lists.php.net to get a copy of this message | ||
If you need the same output as the g_date_get_julian function of the GlibC, here is my php
implementation :
<?php
/**
* Glib g_date_get_julian PHP implementation
*
* @param $str Date string in a format accepted by strtotime
* @author jfg
*/
private function _get_julian( $str )
{
$d = date_create($str);
if( $d == false )
return 0;
$day_in_year = (int) date_format($d, "z");
$year = (int) date_format($d, "Y") - 1;
$julian_days = $year * 365;
$julian_days += ($year >>= 2);
$julian_days -= ($year /= 25);
$julian_days += $year >> 2;
$julian_days += $day_in_year + 1;
return ceil($julian_days);
}
?>
----
Server IP: 89.31.146.176
Probable Submitter: 88.121.3.42
----
Manual Page -- http://www.php.net/manual/en/function.gregoriantojd.php
Edit -- https://master.php.net/note/edit/90138
Del: integrated -- https://master.php.net/note/delete/90138/integrated
Del: useless -- https://master.php.net/note/delete/90138/useless
Del: bad code -- https://master.php.net/note/delete/90138/bad+code
Del: spam -- https://master.php.net/note/delete/90138/spam
Del: non-english -- https://master.php.net/note/delete/90138/non-english
Del: in docs -- https://master.php.net/note/delete/90138/in+docs
Del: other reasons-- https://master.php.net/note/delete/90138
Reject -- https://master.php.net/note/reject/90138
Search -- https://master.php.net/manage/user-notes.php