jdtounix: Julian date to Unix time stamp

Convert a Julian Day count to a Unix timestamp

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 GMT
Unix timestamp to Julian day count

Example 2: Converting Julian Date to Human-Readable Format

After 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

Example 3: Calculating Days Between Julian Dates

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

Example 4: Converting Gregorian Date to Julian Date and Then to Unix Timestamp

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

Calendar Functions


Subscribe to our YouTube Channel here



plus2net.com











PHP video Tutorials
✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer