How to convert Julian day count in php calendar to Unix timestamp

醉折花枝作酒筹
Release: 2023-03-11 20:36:02
Original
2278 people have browsed it

In the previous article, we learned what the French Republican Calendar is, what the Julian Day is, and we also know how "php Calendar's Julian Day Counting and the French Republican Calendar Date Periods" Mutual conversion》, this time let’s take a look at how Julian day counts are converted to Unix timestamps.

Today we will continue this topic to learn other functions in the PHP calendar, but before starting this article, I want to ask you a question. This question is, do you know the Unix timestamp? In order to prevent some friends from not knowing, let’s first explain Unix timestamps.

The unix timestamp is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), regardless of leap seconds.

According to the ISO 8601 specification, the 0 of the UNIX timestamp is: 1970-01-01T00:00:00Z.

The UNIX timestamp format of one hour is: 3600 seconds; One day is expressed as a UNIX timestamp of 86400 seconds, and leap seconds are not counted.

In most UNIX systems UNIX timestamps are stored as 32 bits, which can cause the year 2038 problem or Y2038.

After understanding the relevant knowledge of Unix timestamps, let’s officially start our introduction.

As usual, let’s start with a small case.

It is now known that the Julian day count is 2440590, so what is the Unix timestamp?

Next let’s look at the code:

<?php
echo jdtounix(2440590);
?>
Copy after login

The result is

172800
Copy after login

In this example, we can see that the jdtounixh function is used , follow the case and look at the function to see if you can roughly understand what the function does. In fact, it is very simple. The jdtounixh function converts one number into another number. Now that we know this, let's take a closer look at this function.

Syntax

jdtounix(介于2440588和2465342之间的儒略日数字);
Copy after login

The jdtounix() function converts a Julian day count to a Unix timestamp.

Special attention should be paid to:

If the parameter jd is not in the Unix new era (meaning that the Gregorian year must be between 1970 and 2037, or jd >= 2440588 and jd <= 2465342), the function will return false. The time returned is local time.

Here are the php knowledge you want to learn→php video tutorial

The above is the detailed content of How to convert Julian day count in php calendar to Unix timestamp. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template