Bertram79
Bertram79

Reputation: 3

linux date command is skipping hours

I'm using the date function to calculate the number of hours passed since a set start date, in my case 19010101. This fails for some dates, the first one being for the last hour of 19160514

date -d "19010101 +134710 hours"

Sun 14 May 22:00:00 CET 1916

date -d "19010101 +134711 hours"

Mon 15 May 00:00:00 CEST 1916

23:00 is missing. I also tried

date -d "19160515 -1 seconds"

Sun 14 May 22:59:59 CET 1916

Can anyone explain what is wrong here?

Upvotes: 0

Views: 138

Answers (1)

unconditional
unconditional

Reputation: 7656

Use UTC time zone like this:

date -u -d "19010101 +134711 hours"

Upvotes: 2

Related Questions