0

I'm using the following command in an attempt to work out the time 15 minutes before the timestamp:

/opt/bin/date --date "-15 minutes 2016-04-28T16:58:55" '+%Y-%m-%dT%H:%I:%S'

The problem is the time produced is:

2016-04-28T10:10:55

Which is obviously much earlier than 15 minutes before the stated time.

Does anyone have any ideas why this would be?

Not sure this is relevent, but just so you know, I have to use /opt/bin/date rather than simply date because if I write the command like so:

date --date '-15 minutes 2016-04-27T14:14:47'

I get the error

date: invalid date '-15 minutes 2016-04-27T14:14:47'

PS i'm working with Linux on a synology box- Linux version 3.2.40. gcc version 4.6.4

2

Your format string to date is wrong. %I gives the hour in 12 hour format (01..12), you probably want %M, and then your command seems to work (on this linux box - I don't have a synology to try on).

  • Thanks for the response, i've update my command to the below which includes the correct syntax for 24 time, but the hour is still showing 10 – neilH Apr 28 '16 at 23:20
  • /opt/bin/date --date '-15 minutes 2016-04-28T16:58:55' '+%Y-%m-%dT%H:%M:%S' – neilH Apr 28 '16 at 23:20
  • The command is producing this timestamp 2016-04-28T10:43:55 – neilH Apr 28 '16 at 23:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.