本文整理汇总了PHP中JDToGregorian函数的典型用法代码示例。如果您正苦于以下问题:PHP JDToGregorian函数的具体用法?PHP JDToGregorian怎么用?PHP JDToGregorian使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了JDToGregorian函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetData
function GetData($val)
{
$jd = GregorianToJD(1, 1, 1970);
$gregorian = JDToGregorian($jd + intval($val) - 25569);
return $gregorian;
/**显示格式为 “月/日/年” */
}
示例2: JDtoYMD
function JDtoYMD($date, &$year, &$month, &$day)
{
$string = JDToGregorian($date);
$month = strtok($string, " -/");
$day = strtok(" -/");
$year = strtok(" -/");
}
示例3: GetData
/**
* 规范读入的时间,该函数暂时未用到
* @param unknown $val
* @return string
*/
function GetData($val)
{
$jd = GregorianToJD(1, 1, 1970);
$gregorian = JDToGregorian($jd + intval($val) - 25569);
return $gregorian;
/**
* 格林威治时间的转换
*/
}
示例4: excelTime
function excelTime($days, $time = false)
{
if (is_numeric($days)) {
//based on 1900-1-1
$jd = GregorianToJD(1, 1, 1970);
$gregorian = JDToGregorian($jd + intval($days) - 25569);
$myDate = explode('/', $gregorian);
$myDateStr = str_pad($myDate[2], 4, '0', STR_PAD_LEFT) . "-" . str_pad($myDate[0], 2, '0', STR_PAD_LEFT) . "-" . str_pad($myDate[1], 2, '0', STR_PAD_LEFT) . ($time ? " 00:00:00" : '');
return $myDateStr;
}
return $days;
}
示例5: insertToEventTable
function insertToEventTable($eventName, $eventDate, $duration)
{
$calendar->insert_pistahan($eventDate, $eventName);
// adjust duration
$duration -= 1;
// if duration is already 0, then exit. else call the function again to continue the insert
if ($duration == 0) {
return;
}
$eventDate = JDToGregorian(GregorianToJD(date("m", strtotime($eventDate)), date('j', strtotime($eventDate)), date('Y', strtotime($eventDate))) - 1);
insertToEventTable($eventName, $eventDate, $duration);
return;
}
示例6: gawa_ng_kalendaryo
public function gawa_ng_kalendaryo($year)
{
$numberOfDays = 390;
$newdayofweek = 1;
$weekNumber = 1;
$days = "+0 days";
// check table for the last date on the the table
$query = "SELECT juliandate FROM fiscalcalendar ORDER BY juliandate desc Limit 1";
$result = fetch_record($query);
if ($result['juliandate'] == 0) {
$juliandate = gregoriantojd(01, 01, date('Y', strtotime($year)));
} else {
$juliandate = $result['juliandate'] + 1;
}
// $juliandate = gregoriantojd(01,01,date('Y',strtotime($days)));
echo "<table border='5px'><thead><td>Julian Date</td><td>Gregorian Date</td><td>end of week</td><td>end of month</td><td>week#</td></thead><tbody>";
for ($i = 0; $i <= $numberOfDays; $i++) {
// check for end of week
$days = JDToGregorian($juliandate);
if (date('N', strtotime($days)) == 7) {
$endOfWeek = 'Y';
} else {
$endOfWeek = 'N';
}
// end of year
if (date("m", strtotime($days)) == 12 && date("j", strtotime($days)) == date("t", strtotime($days))) {
$endofyear = 'Y';
} else {
$endofyear = 'N';
}
// end of month
if (date("j", strtotime($days)) == date("t", strtotime($days))) {
$endofmonth = 'Y';
} else {
$endofmonth = 'N';
}
if (date("j", strtotime($days)) == 1) {
$weekNumber = 1;
$newdayofweek = date('N', strtotime($days));
} else {
if ($newdayofweek == date('N', strtotime($days))) {
$weekNumber += 1;
}
}
echo "<tr>" . $juliandate . '</td><td>' . JDToGregorian($juliandate) . '</td><td>' . $endOfWeek . '</td><td>' . $endofmonth . '</td><td>' . $weekNumber . '</td></tr>';
$query = "INSERT INTO fiscalcalendar (juliandate,fdate, fmonth, fday, fyear, endOfWeek, endofmonth, dayOfWeek, weekNumber) VALUES('" . $juliandate . "','" . date("y-m-d", strtotime($days)) . "'," . date("m", strtotime($days)) . "," . date('j', strtotime($days)) . "," . date('Y', strtotime($days)) . ",'" . $endOfWeek . "','" . $endofmonth . "','" . date('N', strtotime($days)) . "'," . $weekNumber . ")";
$result = run_mysql_query($query);
$juliandate += 1;
}
}
示例7: excelTime
function excelTime($date, $time = false)
{
if (function_exists('GregorianToJD')) {
if (is_numeric($date)) {
$jd = GregorianToJD(1, 1, 1970);
$gregorian = JDToGregorian($jd + intval($date) - 25569);
$date = explode('/', $gregorian);
$date_str = str_pad($date[2], 4, '0', STR_PAD_LEFT) . "-" . str_pad($date[0], 2, '0', STR_PAD_LEFT) . "-" . str_pad($date[1], 2, '0', STR_PAD_LEFT) . ($time ? " 00:00:00" : '');
return $date_str;
}
} else {
$date = $date > 25568 ? $date + 1 : 25569;
/* There was a bug if Converting date before 1-1-1970 (tstamp 0) */
$ofs = (70 * 365 + 17 + 2) * 86400;
$date = date("Y-m-d", $date * 86400 - $ofs) . ($time ? " 00:00:00" : '');
}
return $date;
}
示例8: sprintf
$dateinc = sprintf("%04d/%02d/%02d", $dd[2], $dd[0], $dd[1]);
// next day date
//day before
$gregorian = JDToGregorian($jd - 1);
// mm/dd/yyyy
$dd = split("/", $gregorian);
$datedec = sprintf("%04d/%02d/%02d", $dd[2], $dd[0], $dd[1]);
// previous day date
//next two day
$gregorian = JDToGregorian($jd + 2);
// mm/dd/yyyy
$dd = split("/", $gregorian);
$dateinc2 = sprintf("%04d/%02d/%02d", $dd[2], $dd[0], $dd[1]);
// next day date
//next three day
$gregorian = JDToGregorian($jd + 3);
// mm/dd/yyyy
$dd = split("/", $gregorian);
$dateinc3 = sprintf("%04d/%02d/%02d", $dd[2], $dd[0], $dd[1]);
// next day date
// echo "$datedec, |$date|, $dateinc, $dateinc2, $dateinc3\n";
$buffer = fgets($f2);
$j = 0;
while (substr($buffer, 0, 1) == " " and strlen($buffer) > 6) {
$out = "";
//echo " $date-$buffer\n";
#time_start
if (strlen(trim(substr($buffer, 1, 4))) == 4) {
$out .= $date . " " . substr($buffer, 1, 2) . ":" . substr($buffer, 3, 2) . ":00\t";
$et = substr($buffer, 1, 2) + substr($buffer, 3, 2) / 60;
$m_start = substr($buffer, 1, 2) * 60 + substr($buffer, 3, 2);
示例9: setLocalDateAndTime
public function setLocalDateAndTime($id, $date, $time)
{
global $objDatabase, $objLocation;
if ($time >= 0) {
$timezone = $objLocation->getLocationPropertyFromId($this->getDsObservationProperty($id, 'locationid'), 'timezone');
$datearray = sscanf($date, "%4d%2d%2d");
$dateTimeZone = new DateTimeZone($timezone);
$date = sprintf("%02d", $datearray[1]) . "/" . sprintf("%02d", $datearray[2]) . "/" . $datearray[0];
$dateTime = new DateTime($date, $dateTimeZone);
// Returns the timedifference in seconds
$timedifference = $dateTimeZone->getOffset($dateTime);
$timedifference = $timedifference / 3600.0;
$timestr = sscanf(sprintf("%04d", $time), "%2d%2d");
$jd = cal_to_jd(CAL_GREGORIAN, $datearray[1], $datearray[2], $datearray[0]);
$hours = $timestr[0] - (int) $timedifference;
$timedifferenceminutes = ($timedifference - (int) $timedifference) * 60;
$minutes = $timestr[1] - $timedifferenceminutes;
if ($minutes < 0) {
$hours = $hours - 1;
$minutes = $minutes + 60;
}
if ($minutes > 60) {
$hours = $hours + 1;
$minutes = $minutes - 60;
}
if ($hours < 0) {
$hours = $hours + 24;
$jd = $jd - 1;
}
if ($hours >= 24) {
$hours = $hours - 24;
$jd = $jd + 1;
}
$time = $hours * 100 + $minutes;
$dte = JDToGregorian($jd);
sscanf($dte, "%2d/%2d/%4d", $month, $day, $year);
$date = $year . sprintf("%02d", $month) . sprintf("%02d", $day);
}
$objDatabase->execSQL("UPDATE observations SET date = \"" . $date . "\" WHERE id = \"" . $id . "\"");
$objDatabase->execSQL("UPDATE observations SET time = \"" . $time . "\" WHERE id = \"" . $id . "\"");
}
示例10: print_nice_date
function print_nice_date($jd)
{
// format of Thursday, Septemeber 22nd 2012
if ($jd == 0) {
return '';
}
$date = explode("/", JDToGregorian($jd));
$output = jddayofweek($jd, 1) . ", " . jdmonthname($jd, 3) . " {$date[1]}, {$date[2]}";
return $output;
}
示例11: date
if (date("m", strtotime($days)) == 12 && date("j", strtotime($days)) == date("t", strtotime($days))) {
$endofyear = 'Y';
} else {
$endofyear = 'N';
}
// end of month
if (date("j", strtotime($days)) == date("t", strtotime($days))) {
$endofmonth = 'Y';
} else {
$endofmonth = 'N';
}
if (date("j", strtotime($days)) == 1) {
$weekNumber = 1;
$newdayofweek = date('N', strtotime($days));
} else {
if ($newdayofweek == date('N', strtotime($days))) {
$weekNumber += 1;
}
}
echo "<tr>";
echo "<td>" . $juliandate . '</td>';
echo "<td>" . JDToGregorian($juliandate) . '</td>';
echo '<td>' . $endOfWeek . '</td>';
echo '<td>' . $endofmonth . '</td>';
echo '<td>' . $weekNumber . '</td>';
echo '</tr>';
$query = "INSERT INTO fiscalcalendar (\n\t\tjuliandate,\n\t\tfdate, \n\t\tfmonth, \n\t\tfday, \n\t\tfyear, \n\t\tendOfWeek, \n\t\tendofmonth, \n\t\tdayOfWeek, \n\t\tweekNumber) VALUES('" . $juliandate . "','" . date("y-m-d", strtotime($days)) . "'," . date("m", strtotime($days)) . "," . date('j', strtotime($days)) . "," . date('Y', strtotime($days)) . ",'" . $endOfWeek . "','" . $endofmonth . "','" . date('N', strtotime($days)) . "'," . $weekNumber . ")";
// echo $query;die;
$result = run_mysql_query($query);
$juliandate += 1;
}
示例12: sprintf
$dateinc = sprintf("%04d/%02d/%02d", $dd[2], $dd[0], $dd[1]);
// next day date
//day before
$gregorian = JDToGregorian($jd - 1);
// mm/dd/yyyy
$dd = split("/", $gregorian);
$datedec = sprintf("%04d/%02d/%02d", $dd[2], $dd[0], $dd[1]);
// previous day date
//next two day
$gregorian = JDToGregorian($jd + 2);
// mm/dd/yyyy
$dd = split("/", $gregorian);
$dateinc2 = sprintf("%04d/%02d/%02d", $dd[2], $dd[0], $dd[1]);
// next day date
//next three day
$gregorian = JDToGregorian($jd + 2);
// mm/dd/yyyy
$dd = split("/", $gregorian);
$dateinc3 = sprintf("%04d/%02d/%02d", $dd[2], $dd[0], $dd[1]);
// next day date
if (checkdate($mo, $d, $y)) {
$date = sprintf("%04d/%02d/%02d", $y, $mo, $d);
} else {
$date = "";
}
//start time
if (strlen(trim(substr($buffer, 13, 4))) == 4) {
$m_start = substr($buffer, 13, 2) * 60 + substr($buffer, 15, 2);
//start time in minutes
if (substr($buffer, 13, 2) < 24) {
$buf[$i++] = $date . " " . substr($buffer, 13, 2) . ":" . substr($buffer, 15, 2) . ":00";
示例13: fromDays
/**
* Converts number of days since 24th November, 4714 B.C. (in the proleptic
* Gregorian calendar, which is year -4713 using 'Astronomical' year
* numbering) to Gregorian calendar date.
*
* Returned date belongs to the proleptic Gregorian calendar, using
* 'Astronomical' year numbering.
*
* The algorithm is valid for all years (positive and negative), and
* also for years preceding 4714 B.C. (i.e. for negative 'Julian Days'),
* and so the only limitation is platform-dependent (for 32-bit systems
* the maximum year would be something like about 1,465,190 A.D.).
*
* N.B. Monday, 24th November, 4714 B.C. is Julian Day '0'.
*
* Algorithm is from PEAR::Date_Calc
*
* @author Monte Ohrt <monte@ispi.net>
* @author Pierre-Alain Joye <pajoye@php.net>
* @author Daniel Convissor <danielc@php.net>
* @author C.A. Woodcock <c01234@netcomuk.co.uk>
*
* @param int $days the number of days since 24th November, 4714 B.C.
* @param string $format the string indicating how to format the output
*
* @return Horde_Date A Horde_Date object representing the date.
*/
public static function fromDays($days)
{
if (function_exists('JDToGregorian')) {
list($month, $day, $year) = explode('/', JDToGregorian($days));
} else {
$days = intval($days);
$days -= 1721119;
$century = floor((4 * $days - 1) / 146097);
$days = floor(4 * $days - 1 - 146097 * $century);
$day = floor($days / 4);
$year = floor((4 * $day + 3) / 1461);
$day = floor(4 * $day + 3 - 1461 * $year);
$day = floor(($day + 4) / 4);
$month = floor((5 * $day - 3) / 153);
$day = floor(5 * $day - 3 - 153 * $month);
$day = floor(($day + 5) / 5);
$year = $century * 100 + $year;
if ($month < 10) {
$month += 3;
} else {
$month -= 9;
++$year;
}
}
return new Horde_Date($year, $month, $day);
}
示例14: excel_time
/**
*@date 2010-7-22
*@time 上午10:45:39
*/
function excel_time($days = '40368')
{
//function
if (is_numeric($days)) {
$jd = gregoriantojd(1, 1, 1970);
$gregorian = JDToGregorian($jd + intval($days) - 25569);
$myDate = explode('/', $gregorian);
$myDateStr = str_pad($myDate[2], 4, '0', STR_PAD_LEFT) . "-" . str_pad($myDate[0], 2, '0', STR_PAD_LEFT) . "-" . str_pad($myDate[1], 2, '0', STR_PAD_LEFT) . ($time ? " 00:00:00" : '');
return $myDateStr;
} else {
return $days;
}
}
示例15: excelTime
function excelTime($date, $time = false)
{
if (is_numeric($date)) {
$jd = GregorianToJD(1, 1, 1970);
$gregorian = JDToGregorian($jd + intval($date) - 25569);
$date = explode('/', $gregorian);
$date_str = str_pad($date[2], 4, '0', STR_PAD_LEFT) . "-" . str_pad($date[0], 2, '0', STR_PAD_LEFT) . "-" . str_pad($date[1], 2, '0', STR_PAD_LEFT) . ($time ? " 00:00:00" : '');
return $date_str;
}
return $date;
}