Last active
December 6, 2021 20:21
-
-
Save JamesHovious/7652469 to your computer and use it in GitHub Desktop.
PowerShell function to get today's Julian Date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Calculate today's julian date | |
$Year = get-date -format yy | |
$JulianYear = $Year.Substring(1) | |
$DayOfYear = (Get-Date).DayofYear | |
$JulianDate = $JulianYear + "{0:D3}" -f $DayOfYear | |
Write-Host $JulianDate |
Agreed. What you have there is commonly referred to as the Julian Day - days- one-based numbered from 1st Jan. The Julian Calendar is predecessor to Gregorian calendar without the some of leap year adjustments - so as a result they're drifting apart over time.
Also, its much easier to calculate the Julian day using this:
Get-Date -UFormat %j
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice... but wrong. While commonly "called" Julian date, what you represented is NOT a Julian date. Google it.
Julian dates (abbreviated JD) are simply a continuous count of days and fractions since noon Universal Time on January 1, 4713 BC (on the Julian calendar). Almost 2.5 million days have transpired since this date. Julian dates are widely used as time variables within astronomical software. )