1

In Powershell, if I obtain DHCP leases from a server using Get-DHCPServerv4Lease and then convert that to JSON, here is an example output:

....
"LeaseExpiryTime" : "\/Date(1457009853298)\/",
....

My question: What is that date number? Its not Unix timestamp or Windows filetime.

Unix TS:          Thursday, October 20, 48140 11:14:58pm
Windows Filetime: Tuesday, January 2, 1601 4:28:21pm

The lease expiry time in the DHCP console is 3/3/2016 7:57:33 AM EST. The best I've been able to come up with is chopping off the last three digits, which turns it into a proper Unix timestamp and gives me the correct time in UTC (my TZ is EST).

Of course, if I ConvertFrom-Json I get a proper DateTime object, albeit in UTC rather than EST:

$data | ConvertFrom-JSON
....
LeaseExpiryTime : 3/3/2016 12:57:33 PM

I can't seem to make a correct date using Get-Date or even any methods in [DateTime]:: using that '1457009853298'

Running Get-Date | Convertto-JSON gives me the below, but I still don't know what I can do with that value.

{
"value":  "\/Date(1456939716572)\/",
"DisplayHint":  2,
"DateTime":  "Wednesday, March 2, 2016 12:28:36 PM"
}
Ben
  • 63
  • 2
  • 7
  • [See TheMadTechnician's answer](http://stackoverflow.com/a/26068643/3905079) in the linked question. – briantist Mar 02 '16 at 17:38
  • Thank you @briantist! Apparently I need to work on my searching skills. – Ben Mar 02 '16 at 17:56
  • 3
    I typically can't find duplicates with SO's search and end up finding them in google while researching the question! – briantist Mar 02 '16 at 17:59
  • 1
    Also these had more information related to my use: [Format a Microsoft JSON date](http://stackoverflow.com/questions/206384/format-a-microsoft-json-date) [JSON PHP Format Date](http://stackoverflow.com/questions/16749778/php-date-format-date1365004652303-0500) – Ben Mar 02 '16 at 17:59

0 Answers0