1

Every time I type in

date -d @1588560000

in the windows command prompt, I get the following message

C:\Users\msaad>date -d "@1588501800"
The system cannot accept the date entered.
Enter the new date: (mm-dd-yy)`

Can anyone help me with this?

Saad Hassan
  • 313
  • 2
  • 10
  • 1
    Does [this](https://stackoverflow.com/q/10781697/11942268) answer your question? You should also be a little more specific. You tagged the question as "powershell", but said your are using "command prompt". So what are you using? If you use PowerShell, you can show us the output of `Get-Command date` to tell us more about the tool you are using. – stackprotector May 04 '20 at 05:09

1 Answers1

3

I set the unix timestamp date 0 and add it that number of seconds:

(Get-Date -Date "1970-01-01 00:00:00Z").toUniversalTime().addSeconds(1588560000)
jeprubio
  • 17,312
  • 5
  • 45
  • 56
  • Will that add 1588560000 seconds to 01.01.1970 00:00:00 in UTC or to 01.01.1970 00:00:00 in your specific time zone? – stackprotector May 04 '20 at 06:20
  • @Thomas is in UTC – jeprubio May 04 '20 at 07:08
  • 1
    `(Get-Date 01.01.1970).Kind` returns `Unspecified` on my machine (PowerShell 5.1), that's why I am asking. This may lead to ambiguousness when you want to process this date with other dates that are not `Unspecified`, e.g. `Local` or `Utc` ([see docs](https://learn.microsoft.com/de-de/dotnet/api/system.datetimekind?view=netcore-3.1#System_DateTimeKind_Unspecified)). But the UNIX epoch is definitely UTC. – stackprotector May 04 '20 at 07:20
  • @Thomas is correct. You must create the unix epoch date as UTC, and your code doesn't do that. – Theo May 04 '20 at 08:59
  • 2
    @Theo OK, I've updated the answer, now it returns kind Utc – jeprubio May 04 '20 at 09:20
  • @jeprubio Is the above what I need to type into the windows command prompt? Because when I copy-paste that in the windows command prompt, it still doesn't work – Saad Hassan May 06 '20 at 04:15
  • In powershell? It should work. Do you get any error message? – jeprubio May 06 '20 at 05:37