Bash Script Convert Julian Date To A Calendar Date

Converting date formats can be a tricky thing. Two of the more cryptic formats that come up in our support questions relate to Julian dates and Unix timestamps. Here's how you convert them in Strata:

Julian Dates

Does anyone know of a way to convert from a Julian date to a regular calendar date? Stack Exchange Network Stack Exchange network consists of 176 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

If you hover over the julian-date tag it says: The term 'Julian date' also refers to the day-of-year number (more properly, the ordinal date) in the Gregorian calendar, especially in computer programming, the military and the food industry. – Squashman Jan 13 '16 at 22:44. Hi, I have script in unix which creates a julian date like 126 or 127 I want convert this julian date into calender date ex: input 127 output 07/may/2007 or or 07/05/07 rgds srikanth (6 Replies).

A Julian date is the number of days since January 1, 4713 BC GMT. To convert a Julian date to the current date, you can simply use DATE(0,0,0) + <number>, where <number> is the Julian date. For for example, if the number appears as “2454917″, the formula in Strata would be:

date(0,0,0) + 2454917 [the result would be March, 26, 2009]

Bash

Unix Timestamps

A unix timestamp is the number of seconds since 1970. To convert a unix timestamp to the current date, use DATE(<number>), where <number> is the number of milliseconds since 1970. If the timestamp is given in seconds, multiply by 1000: DATE(<number>*1000). So, for example, if you the number appears as “1237657172″, the formula in Strata would be:

date(1238088021 * 1000) [the result would be March, 26, 2009]

As a side note, sometimes one might mistake a Julian or Unix date for a different custom format. For instance, dates could be stored in the format YYDDD or YYYYDDD where YY/YYYY is the year, and DDD is the number of days since the beginning of that year. So 2001003 would be January 3, 2001

For further information on Strata date conversion, please see this help page.

This converter requires the use of Bash script convert julian date to a calendar date 2020Bash script convert julian date to a calendar date 2020Bash Script Convert Julian Date To A Calendar DateJavascript enabled and capable browsers. This script creates a calendar converter that can convert five different units at one time; that is actually converting between the Gregorian Calendar, Julian Calendar and Julian Date, and translating those into the Roman and Latin versions of the Julian Calendar. The information provided below the converter is from our page sponsor and is very helpful to the details and understanding of calendar differences.

Notes for Use

  • The Gregorian calendar was introduced in 1582 AD and so before this year, dates have been extrapolated using the standard rules for Gregorian leap years. Years are valid to 2400 AD.
  • The Julian calendar was introduced in 45 BC and so before this year, dates have been extrapolated using the standard rules for Julian leap years.
  • Julian years are implemented as starting on 1st January and not the 26th March as in some calendars.
  • The Roman calendar was introduced circa 750 BC and so dates before 753 BC are not allowed. The Roman calendar changed frequently with varying year lengths and so the days and months are not valid before 8 AD and are only presented for illustration purposes.
  • Between 45 BC and 8 AD, the leap years in the Julian calendar do not follow the standard rules and the following leap years are implemented in the above algorithm: 45 BC, 42 BC, 39 BC, 36 BC, 33 BC, 30 BC, 27 BC, 24 BC, 21 BC, 18 BC, 15 BC, 12 BC, and 9 BC.
  • The conversion between Julian Year and Gregorian Year may contain an error of +/- 1 day compared to some calendars. This is due to the complex method of calculating dates and often occurs in years which are leap years in the Julian calendar but not in the Gregorian calendar (or vice versa).
  • The Julian Date is calculated for 12:00 midday for the day in question and ranges are valid from 1446656 (753 BC) to 2598007 (2400 AD).

The Years
Roman Calendar
The Romans counted their years from a variety of important dates. The most important of these dates was the founding of Rome which is labeled a.u.c. (anno urbis conditae - from the year of the founding of the city). To convert a.u.c. to AD, subtract 753 (or 754 for BC years). Thus:

  • a.u.c. CDXXXVI = a.u.c. 436 = (436-754)BC = 318 BC
  • a.u.c. CMXIII = a.u.c. 913 = (913-753)AD = 160 AD

Julian Calendar
The Roman years had a various numbers of days and it was only when Julius Caesar introduced the Julian year in 46 BC that years had 365 days with a leap year every four years. Unfortunately, the leap years were not correctly implemented until 8 AD - a mix up meant they came every third year instead of every fourth until 9 BC and then Emperor Augustus scrapped leap years until 8 AD. Note that there is no zero year and the year 1 BC is followed by 1 AD. Some records incorrectly state that the first day of the Julian year occurs on March 26th.

Gregorian Calendar
The Gregorian calendar has leap years every four years, like the Julian calendar. However, the Gregorian calendar skips leap years when years are divisible by 100 (but not by 400) To ensure the vernal equinox of the Gregorian year falls on March 25th, ten days were 'removed' from the Gregorian calendar and the 4th October 1582 (Julian Calendar) was followed by 15th October 1582 (Gregorian Calendar).

Unfortunately, the Gregorian calendar did not become standard across the world for hundreds of years and so it can be a little confusing analyzing dates after its introduction.

The Months
Roman Calendar
The Romans had twelve months, just like we do, but they began with March. The months gradually acquired their names over time and some are named after the month number and some are named after people or gods. The months are:

no.GregorianRomanNamed After
11JanuaryIanuariusJanus - God
12FebruaryFebruariusFebrua - festival
1MarchMartiusMars - God
2AprilAprilis?
3MayMaiusMaia - Goddess
4JuneIuniusIuno - Queen of the Gods
5JulyIulius / QuinctilisIulius - Caesar / 5 (quinque)
6AugustAugustus / SextilAugustus - Emperor / 6 (sex)
7SeptemberSeptember7 (septem)
8OctoberOctober8 (octo)
9NovemberNovember9 (novem)
10DecemberDecember10 (decem)

Julian and Gregorian Calendar
The months in the Julian calendar are identical to the Gregorian calendar.

The Days of the Month
Roman Calendar
The Roman days of the month are a little different to ours. They had key days on each month and each day of the month is given as the number of days (including both the day in question and the key day) to the next key day.

To illustrate this, the key days are:

  • Kal. (Kalendae) - Kalends is the first day of each month
  • Non. (Nonae) - Nones are the ninth day before the Ides - i.e. the 5th (or 7th) day
  • Id. (Idus) - Ides are the 13th day of each month (in March, July, October, and May, the Ides is the 15th day)

For the key day of the month, the day is given by [key day] [month]. So Jan 5th would be Nonae Ianuariis - abbreviated to Non. Ian.

For the day of the month immediately before the key day, the day is given by: 'pridie' [key day] [month of key day]. So the Dec 31st would be pridie Kalendas Ianuarias - abbreviated to prid. Kal. Ian.

For the other days of the month, the day is given by: 'ante diem' [no. days to next key day] [key day] [month of key day] where the number of days to the next key day includes both the day in question and the key day. So the Jan 8th comes 6 days before the Ides of January (8,9,10,11,12,13) and so would be ante diem VI Idus Ianuarias - abbreviated to a.d. VI Id. Ian.

Between 45 BC and 8 AD, January, March, May, July, September, and November each had 31 days while the other months each had 30 days except February which had 29 days in standard years and 30 days in leap years. In 8 AD, this was changed by Emperor Augustus so that his month (August) could have 31 days and the days of the months were rearranged and ended up in their current form.

The Days of the Week
The seven day week became standard around the 3rd Century. The days of the week took their names from the heavenly bodies as follows:

DayRoman DayNamed After
Mondaydies LunaeThe Moon
Tuesdaydies MartisMars
Wednesdaydies MercuriiMercury
Thursdaydies IovisJupiter
Fridaydies VenerisVenus
Saturdaydies SaturniSaturn
Sundaydies SolisThe Sun

The Latin days of the month kept these names apart from Sunday which was replaced by 'dies Dominicus' (the Lord's day) in many Christian groups.

Bash Script Convert Julian Date To A Calendar Date Calendar

The Julian Date
The Julian date is the amount of days since 12 midday January 1st 4713 BC. This date is really arbitrary and was only chosen to align the records of various accounting practices. It is mainly used in astronomical circles as it provides a continuous linear date that is simple to work with. It also provides an easy method of quickly finding how many days are between two dates. For example, to find the 1000th day after Jan 1st 2000 (Julian date=2451545), we add 1000 to the Julian date (2452545) and find that the day is Friday 27th September 2002.