PHP.mk документација

jdtogregorian

Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.

function.jdtogregorian.php PHP.net прокси Преводот се освежува
Оригинал на PHP.net
Патека function.jdtogregorian.php Локална патека за оваа страница.
Извор php.net/manual/en Оригиналниот HTML се реупотребува и локално се стилизира.
Режим Прокси + превод во позадина Кодовите, табелите и белешките остануваат читливи во истиот тек.
jdtogregorian

Референца за `function.jdtogregorian.php` со подобрена типографија и навигација.

function.jdtogregorian.php

jdtogregorian

(PHP 4, PHP 5, PHP 7, PHP 8)

jdtogregorianКонвертира Јулијанскиот ден во Грегоријански датум

= NULL

jdtogregorian(int $julian_day): string

Converts Julian Day Count to a string containing the Gregorian date in the format of "month/day/year".

Параметри

julian_day

Јулијански број на ден како цел број

Вратени вредности

Грегоријанскиот датум како стринг во форма "месец/ден/година"

Види Исто така

  • gregoriantojd() - Конвертира Грегоријански датум во Јулијански ден
  • cal_from_jd() - Конвертира од Јулијански ден во поддржан календар

Белешки од корисници 5 белешки

httpwebwitch
21 години пред
JD days may have decimal fractions which correspond to the time of day. The Julian day begins at noon, and the decimal fraction measures fractional days until the beginning of the next day at noon.

For instance, Julian Day 2453179.00000 is June 22, 2004, at 12:00pm (noon). 

One hour later, it's 2453179.04167
At 2453179.20833 I'll have dinner, and
at 2453179.45833, it's time for the evening news.
After a good night of sleep, my alarm will go off at 2453179.83333, 
then at noon on June 23, a new Julian Day begins at 2453180.

To use these functions with fractional days, strip the fractional part with floor(), and apply the function to the integer part. 

Then add 12 hours, bringing you to noon of that day. That is the actual time returned by JDToGregorian().

Then add the fractional part of the day, by multiplying the decimal part of the Julian Day by (24*60*60) seconds. This may take you forward or backward to a different Gregorian calendar date.
treebe
пред 22 години
Julian to Gregorian date change.
If you do not have the calendar extensions loaded this is little function works realy well.

<?php
function jd_to_greg($julian) {
    $julian = $julian - 1721119;
    $calc1 = 4 * $julian - 1;
    $year = floor($calc1 / 146097);
    $julian = floor($calc1 - 146097 * $year);
    $day = floor($julian / 4);
    $calc2 = 4 * $day + 3;
    $julian = floor($calc2 / 1461);
    $day = $calc2 - 1461 * $julian;
    $day = floor(($day + 4) / 4);
    $calc3 = 5 * $day - 3;
    $month = floor($calc3 / 153);
    $day = $calc3 - 153 * $month;
    $day = floor(($day + 5) / 5);
    $year = 100 * $year + $julian;

    if ($month < 10) {
        $month = $month + 3;
    }
    else {
        $month = $month - 9;
        $year = $year + 1;
    }
    return "$day.$month.$year";
}
?>
swiles на ddbc dot edu dot tw
пред 17 години
The php gregoriantojd() and jdtogregorian() functions, in addition to the limitations noted by httpwebwitch, does not take account of the 'Astronomical' system of reckoning - i.e. using a year zero, instead of going directly from 1BCE to 1CE, as with the Christian Anno Domini system.

These functions can be used to wrap the php built-ins to return ISO 8601 compliant dates:

<?php
function ISO8601toJD($ceDate) {
    list($day, $month, $year) = array_map('strrev',explode('-', strrev($ceDate), 3));
    if ($year <= 0) $year--;
    return gregoriantojd($month, $day, $year);
}

function JDtoISO8601($JD) {
    if ($JD <= 1721425) $JD += 365;
    list($month, $day, $year) = explode('/', jdtogregorian($JD));
    return sprintf('%+05d-%02d-%02d', $year, $month, $day);
}
?>
ashton на ieee dot org
пред 9 години
The minimum acceptable input Julian day count is 1, which produces an output of "11/25/-4714" (at least in my operating system and location) which means 25 November 4714 BC. PHP does not recognize the year 0. Astronomers do use the year 0, and would write the Gregorian date that corresponds to Julian day number 1 as 25 November -4713.
uni_fl4r3 на t hotmail dot com
пред 22 години
I have made a slight modification to treebe's jd to greg function, this one will transform a unix timestamp to Gregorian day/month/year format...

<?php
function unix_to_greg($unix_timestamp) {
    $julian = floor(((($unix_timestamp / "60") / "60") / "24") + "2440588");
    $julian = $julian - 1721119;
    $calc1 = 4 * $julian - 1;
    $year = floor($calc1 / 146097);
    $julian = floor($calc1 - 146097 * $year);
    $day = floor($julian / 4);
    $calc2 = 4 * $day + 3;
    $julian = floor($calc2 / 1461);
    $day = $calc2 - 1461 * $julian;
    $day = floor(($day + 4) / 4);
    $calc3 = 5 * $day - 3;
    $month = floor($calc3 / 153);
    $day = $calc3 - 153 * $month;
    $day = floor(($day + 5) / 5);
    $year = 100 * $year + $julian;
    
    if ($month < 10)
    {
        $month = $month + 3;
    }else{
        $month = $month - 9;
        $year = $year + 1;
    }
    return "$day.$month.$year";
}
?>
На оваа страница

Автоматски outline од активната документација.

Насловите ќе се појават тука по вчитување.

Попрегледно читање

Примерите, changelog табелите и user notes се визуелно издвоени за да не се губат во долгата содржина.

Брз совет Користи го outline-от Скокни директно на главните секции од активната страница.
Извор Оригиналниот линк останува достапен Кога ти треба целосен upstream context, отвори го PHP.net во нов tab.