date -j -f seems to mix seconds and minutes from the current time of the day while still accepting
'%H%p' in the time format. All I want to do is convert input format to correct unix time. Also, changing
%Z's value to anything other than system's timezone gives an error.
❯ /bin/date -j -f '%H%p %Z' '11PM PDT' '+%s'; gdate -d '11PM' '+%s' 1653546964 1653544800 # Run again ❯ /bin/date -j -f '%H%p %Z' '11PM PDT' '+%s'; gdate -d '11PM' '+%s' 1653546965 1653544800
What do I want?
- Not make the minutes/seconds of the time I run the command affect the result
- Make any timezone work for
I am ok with another POSIX compliant way to get this done if it is unnecessarily difficult with date.
I am using zsh, so a zsh solution could also work, if any. strftime -r seems promising, but produces negative values.