I want to ask your that how to determine & convert current time to no of seconds elapsed during current day?
Actually, I want to show how long is midnight from now in seconds. As total seconds in a day is 86400 so I'll subtract current time (in seconds elapsed since this day) with 86400.
EDIT:
Here is the actual question. If date -d
is not working then how can our instructor give question like this. There might be a way maybe. Anyone understand this question. They have a different way that is subract from no of seconds.
-d
parameter in date command to calculate no of seconds until midnight. Solution below is great, but -d is ot working. Thanks – Zeus Jul 16 '16 at 02:40date
command - for a more platform-independent solution you might want to look at languages that provide their own datetime functions, such asperl
– steeldriver Jul 16 '16 at 02:45date -d
doesn't work. Any idea? – Zeus Jul 16 '16 at 02:50date
with respectively+%H
,+%M
,+%S
and basic arithmetic (in the syntax appropriate for the shell of your instructor's choice). Then - assuming you aren't expected to account for the possibility of leap seconds occurring before tomorrow - simple subtraction will give you the number of seconds remaining until next 00:00:00 – steeldriver Jul 16 '16 at 03:33