does get-date keep an absolute numerical value for a date and time starting from a specific date/epoch (ex. 1970). I know you can increment the get-time with a method. But I wanted to see how it compares two dates together.
Every DateTime object returned by Get-Date has the Ticks property which is probably what you’re looking for.
PS C:\> (Get-Date).Ticks 635488748312963475 PS C:\> Get-Date | Get-Member -Name Ticks TypeName: System.DateTime Name MemberType Definition Ticks Property long Ticks {get;}
Source:http://msdn.microsoft.com/en-us/library/system.datetime.ticks(v=vs.110).aspx
The value of this property represents the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001
Yes, numerical value of a datetime object is the number of 100 nanoseconds after Jan 1, 0001 AD.
thanks for the answers. this question is also an academic one, as I am not solving a problem but want to understand powershell
when you do (get-date).datetime you can compare it to another date. how does powershell compare the dates from a value of say, Tuesday, October 14, 2014 9:42:57 PM? It that date an intelligent object that powershell knows its hidden numerical value or does it just read the string October 14 and know that it comes before November 5.?
when I do a (get-date).datetime | gm I get a "Chars ParameterizedProperty char Chars(int index) {get;}. " Is that the clue to my question?
You’ll need to look into the DateTime implementation of the .NET Framework for the answer. The DateTime class is using the Ticks mentioned earlier to compare dates. What you need to understand is that PowerShell is build on top of the .NET Framework which provides most of the functionality.