Gianluca Ghettini Gianluca Ghettini - 4 months ago 7x
Linux Question

Convert an ISO date to seconds since epoch in linux bash

I have a date in the ISO format YYYY-MM-DDTHH:SS (e.g. 2014-02-14T12:30). I'd like to convert it in seconds since epoch using only the date command in linux bash.

All the dates refer to UCT locale.

I know that this question is easily eligible for duplicate... there are billions of questions about converting dates from one format to another but I can't find my particular scenario

thank you...


With GNU date, specify the date to parse with -d and seconds since epoch with %s

$ date -d"2014-02-14T12:30" +%s