jdtounix() converts a supported Julian Day count to a Unix timestamp.
$timestamp = jdtounix(gregoriantojd(9, 14, 2026));
date_default_timezone_set('UTC');
echo date('Y-m-d', $timestamp);Current example first; the detailed examples and demos below are retained for additional learning and comparison.
\ = cal_to_jd(CAL_GREGORIAN,2,2,2010); // Julian Day count
\=jdtounix(\); // Unix time stamp
echo date('m/d/y',\);// In date format
The output is here 02/02/10
We can get unix time stamp by using gdtounix() function. Here we will use Julian Date ( Integer )as input.
jdtounix(JD_day);
Here is an example.
Note: jdtounix() returns the local time, where Unix Timestamp generator uses GMTAfter converting the Julian Day number to a Unix timestamp, you can format it to a human-readable date:
$jd = 2459580;
$unix = jdtounix($jd);
echo date("Y-m-d H:i:s", $unix);
// Outputs: 2022-03-28 12:00:00
You can calculate the number of days between two Julian dates by converting both to Unix timestamps:
$jd1 = 2459580;
$jd2 = 2459585;
$days_diff = ($jd2 - $jd1);
echo "Difference in days: " . $days_diff;
// Outputs: Difference in days: 5
This example shows how to convert a Gregorian date to a Julian date and then to a Unix timestamp:
$gregorian_date = gregoriantojd(3, 28, 2022);
$unix_timestamp = jdtounix($gregorian_date);
echo date("Y-m-d", $unix_timestamp);
// Outputs: 2022-03-28
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.