Use now()
to know the difference between the certificate expiration date (as a Unix timestamp) and the time the item was last checked. This item can have a daily interval.
See https://www.zabbix.com/documentation/6.0/en/manual/appendix/functions/time
Update: sample script to get expiration date as Unix timestamp.
#!/bin/bash
url="$1" # example.com
# Retrieve the certificate and extract the expiration date
expiration_date=$(echo | openssl s_client -connect $url:443 -servername $url 2>/dev/null | openssl x509 -noout -enddate | cut -d "=" -f 2)
# Convert the expiration date to Unix timestamp
expiration_timestamp=$(date -d "$expiration_date" +"%s")
# Print the results
echo "$expiration_timestamp"
Using timestamp
as the Item unit in Zabbix, allows Zabbix to display the timestamp as human readable in Latest Data.