View Single Post
Old 02-15-2017, 01:35 PM   #28
Hanspeter
Connoisseur
Hanspeter doesn't litterHanspeter doesn't litter
 
Posts: 77
Karma: 150
Join Date: Jul 2014
Device: Kindel PW1, Voyager
Quote:
Originally Posted by knc1 View Post
Works for me:
Code:
 ~ $ date +'%I:%M'
03:37
Which is my local time, not UTC.
Yep, it gives me the twelve hour time too. But what I need is a statement that gives on my Kindel (witch is set to 24Hour clock, not AM/PM) the 24 Hour time without seconds and on an other Kindle that is set to 12 AM/PM hour clock the 12 hour time including AM/PM.

From my point of view I have three possibilities:
1) I would need to find a way to tell the date statement to decide this on the fly
2) Add an If to the statement and use a different format string depending on the result
3) Add an If statement and duplicate all versions of the may statement with different format stings.

Version 3 would be the easiest, but I do not like that stile of coding to simply multiply all lines on the same call only with a small different template.

I think date +%X gives me what I need, but I would need some awk or sed command around it to remove the seconds:
Code:
~$ date +%X
19:32:13
I would expect that you would get '07:32:13 PM'

Hape
Hanspeter is offline   Reply With Quote