Solved how to convert dates?

Hello,

I am trying to write my (first) patch for ssl-certificate-expiry from sysutils/munin-contrib, I need a web server TLS certificate expiration check.

I am still fighting with the date command while trying to convert dates, it's giving me headaches.


# valid_until_string=$(date -j '+%b %e %T %Z %Y %Z')
# echo $valid_until_string
Jan 22 11:35:01 CET 2020 CET


So far, so good. But now, when I would like to convert this string with the very same format variables, I get an error:

# date -j -f '%b %e %T %Z %Y %Z' $valid_until_string '+%s'
Failed conversion of ``Jan'' using format ``%b %e %T %Z %Y %Z''


But according to strftime(), '%b' is 'replaced by national representation of the abbreviated month name'. So 'Jan' is correct.

Any ideas?
 
Try putting the $valid_until_string between ""
Yeah, it looks like that's the problem. The $valid_util_string contains spaces, which causes it to be parsed as separate arguments.
 
Back
Top