Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

How to check if date format is correct?

$
0
0
Hi! how do i know if the input is the same as the required date format? the date should be dd/mm/YYYY ex. 2/3/2012 or 15/11/2012

all the following conditions must return an error:
*input of string
*day is > 31 or < 1
*month is > 12 or < 1
*year is < 2013

suppose the date format is stored in a variable start_date. i want it to be something like:
start_date="some code here"
so that i can do the following if condition:
Code:

if input == start_date
  echo "correct format!"
else
  echo "incorrect format!"

tnx in advance for the answers :)

Viewing all articles
Browse latest Browse all 16232

Trending Articles