JavaScript Stardate Converter

These conversion routines convert to and from Star Trek: The Next Generation style Stardates. These stardates take the form YYXXX.XX where the first two digits refer to the year with 2323 being year zero and the remaining digits being the decimal portion of the year. The last digit before the decimal point is one stardate and is approximately eight and three quarters hours in length.

This first conversion is rather crude and actually makes stardates different lengths in leap years and non leap years. It can handle dates from any year. Dates before 2323 are preceedes by a minus sign, however they numbers showing the portion of the year elapsed still flow in a poitive direction (ie: -20999.99 is followed by -19000.00). Years before 2223 or after 2423 have a three digit year number and are therefore of the form YYYXXX.XX

The program assumes you are entering the date and time as the Gregorian calendar and GMT.

Date to Stardate Converter

This second function is the reverse of the first and converts stardates to Gregorian dates and GMT time. It is possible to get strange results by putting minus signs or decimal points in the wrong place (eg: 5.6-6790) I may get around to writing some code to catch this, but then again, I may find something better to do with my time. Another odd thing is that JavaScript (or just this script?) can't handle years below 100 CE so any stardate before -2223000.00 will return a wrong answer.

Stardate to Date Converter

This last function also converts from Gregorian/GMT dates into stardates but assumes a standard year length of 365.2425 days and thus has stardates of equal length regardless of whether the Gregorian year is a leap year or not. Stardates generated by this method will differ by a small amount to those generated by method one. I have yet to write the code to convert back from this "quad-cent calendar" to the Gregorian calendar but as they are rarely more than a few hours different there is little urgency for me to do so at the moment.

Date to Stardate Converter
Method Two: more accurate but only works
for years between 2323 and 2423.

March 2004 - A note about the 'current' dates at the top of the page. As present and Trek leap years don't line up (TNG Year 1 was 1987 and 2364) there are sometimes small discrepancies between the 'current' date and the date obtained from the main calculator.

August 2000 - Recently I've fixed a leap year bug (wherein the script made every month in a leap year 29 days long and not just February) and added the routine to display the current stardate. Opera 4 handles the scripts properly which is a big improvement over Opera 3.

For more information on stardates refer to the Stardates in Star Trek FAQ by Andrew Main, which is posted monthly to the newsgroup.

On average I get a request a month asking if I will let this script be used on another web site. My answer is always no. This script is accessible to everyone here, this site isn't going anywhere and hence there is no need for it to reproduced anywhere else. If I ever find that anyone has copied this script then I will take steps, up to and including legal action, to have the copy removed.

Last updated November 26th 2005. © Stephen Pugh. [Home page] [E-mail]
Star Trek™, ® & © by Paramount Pictures. All Rights Reserved.
Star Trek is a registered trademark of and all characters and related marks are trademarks of Paramount Pictures.