Convert Zulu timestamp to seconds since epoch and compare it with current time in bash script Mac

Viewed 262

I have below timestamp, which I need to change to seconds since epoch in a bash script, Mac OS and compare with current system time.

2021-09-21T06:27:15Z

Current System Time is in IST format. i.e Tue Sep 21 12:20:42 IST 2021

Please suggest a better way to achieve it.

1 Answers

This should give you what you want:

#!/bin/bash

date="2021-09-21T06:27:15Z"

epoch=$(date -d "${date}" +%s)
Related