[ask]date variable

Is there date variable in bash?

for example, I have string 01-23-2010 (mm-dd-yyyy) or 23-01-2010 (dd-mm-yyyy).
How can I convert that string to date variable?

and how to do some math operation based on date?
for example, today is 12-11-2010.
I want to know date 100 days after today or 50 days before today.
Is there any simple calculation to do that?
thanks

The gnu date command does date arithmetic. There are no date datatypes in bash like there are in databases like Oracle.

If you look at the top bar on this page you will see "man pages". There is a linux man page for date. Try it.

sorry, but I'm new to bash. I already read the manual, but I don't know how to use it..:confused:

How can I assign string to date?

I tried this command, but doesn't work..

start=$(date --utc --date "22-02-2010" "+%d-%m-%Y")

is there anything wrong with that command?

$
$ start=$(date -u -d "22-Feb-2010")
$
$ echo $start
Mon Feb 22 00:00:00 UTC 2010
$

tyler_durden

1 Like