how to convert a date time string to an integer in bash shell

shell

Solution

date --date="Wed Mar 13 00:18:06 2013" '+%s'
date --date="2013-04-06" '+%s'

Only works for gnu date.

Problem

Given a string like '2013-04-06', I want to convert it to a integer as we can do in Java.I have no idea how to do this in bash shell.Does anybody know how to do this?Thanks for any help.

Original source

Related problems