PHP frenchtojd() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
Calendar

Definition

In PHP, frenchtojd() converts a French Republican date into a Julian Day number.

The French Republican calendar was used in France from 1793 to 1805. It has 12 months of 30 days plus 5 or 6 extra days at the end, and it counts years from 1792. PHP supports years 1 to 14, so this function is mostly a curiosity or a history tool.

Syntax

Call frenchtojd() with the values you need. Start with this line.

PHP
$jd = frenchtojd(1, 1, 1);
CallWhat it does
frenchtojd(1, 1, 1)Returns 2375840, the first day of the calendar, which was September 22, 1792.
frenchtojd(2, 18, 8)Returns 2378444, the day Napoleon took power on November 9, 1799.
frenchtojd(1, 1, 15)Returns 0 because the year 15 is outside the supported range.

Use jdtogregorian() on the result to see the normal date. Month 13 stands for the 5 or 6 extra days at the end of the year. The argument order is month, day, year.

Library declarations
PHP
frenchtojd(int $month, int $day, int $year): int

Parameters

ParameterDescription
monthRequired. The month number from 1 to 13, where 13 holds the extra days at the end of the year.
dayRequired. The day of the month from 1 to 30.
yearRequired. The French Republican year, from 1 to 14.

Return Value

Return ValueDescription
intThe Julian Day number for the date. It returns 0 for an invalid date or a year outside 1 to 14.

PHP Examples

Example 1 — Start of the Republican Calendar

Convert the first day of year 1 and year 2, then show them as normal Gregorian dates.

PHP
<?php
$day1 = frenchtojd(1, 1, 1);
$day2 = frenchtojd(1, 1, 2);

echo $day1, PHP_EOL;
echo jdtogregorian($day1), PHP_EOL;
echo $day2 - $day1, PHP_EOL;
echo jdtogregorian($day2), PHP_EOL;

How It Works

  1. frenchtojd(1, 1, 1) is the first day of the calendar, number 2375840.
  2. jdtogregorian() shows that this day is September 22, 1792.
  3. Subtracting the two Julian Days shows that French year 1 had 365 days.
  4. Year 2 starts exactly one year later, on September 22, 1793.

Example 2 — Invalid and Extra Days

Out-of-range input returns 0. The 13th month holds the extra days at the end of the year.

PHP
<?php
var_dump(frenchtojd(1, 1, 0));
var_dump(frenchtojd(1, 1, 15));
var_dump(frenchtojd(14, 1, 5));

echo frenchtojd(13, 5, 1), PHP_EOL;
echo jdtogregorian(frenchtojd(13, 5, 1)), PHP_EOL;

How It Works

  1. Year 0 is not part of the French calendar, so the result is 0.
  2. Year 15 is beyond the supported range, so this also returns 0.
  3. There is no month 14, so that call returns 0 as well.
  4. Month 13, day 5 of year 1 is the last day of the year, which is September 21, 1793.

Example 3 — Napoleon's Coup

The 18th of Brumaire, year VIII (month 2, day 18, year 8) is a famous date. Convert it and find the weekday.

PHP
<?php
$jd = frenchtojd(2, 18, 8);

echo $jd, PHP_EOL;
echo jdtogregorian($jd), PHP_EOL;
echo jddayofweek($jd, 1), PHP_EOL;

How It Works

  1. Brumaire is the 2nd month of the Republican calendar and the year is VIII, which is 8.
  2. frenchtojd(2, 18, 8) returns the Julian Day number 2378444.
  3. jdtogregorian() converts it to November 9, 1799.
  4. jddayofweek() with mode 1 returns the full weekday name.

Frequently Asked Questions

It converts a date from the French Republican calendar into a Julian Day number. You can then convert that number into a Gregorian date with jdtogregorian().
It was a calendar made during the French Revolution. It had 12 months of 30 days and a short 13th period of extra days. France used it from 1793 until it went back to the Gregorian calendar in 1806.
Years 1 to 14 only. Anything else returns 0, because the calendar was only in official use for that time.
The month, day or year is outside the allowed range. Months go from 1 to 13, days from 1 to 30 and years from 1 to 14.
Yes. The calendar extension must be enabled. If PHP says the function is undefined, add extension=calendar to php.ini or install php-calendar.

Next: gregoriantojd()

gregoriantojd() converts a Gregorian date into a Julian Day number.

gregoriantojd() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful