Linux Forums - Linux Help,Advice & support community:LinuxSolved.com
Others => Miscellaneous => Topic started by: universal on June 22, 2009, 03:16:07 PM
-
I'm trying to write a function that will take a date in a certain format as an argument. (Say 2/13/87) Then using if then statements if the argument date is formatted correctly(2/13/87) note it can be any date, then the date will show formatted a different way (Say 1987-2-13) if no date is entered then I need it to return just the current date.
-
This is a copy of what I have so far any help would be appreciated Thanks
function date2my()
{
date --date="$1" +"%m/%d/%y"
if [ "1" ]
then
echo "$1" +"%Y-%m-%d"
else
echo `date`
fi
}