title: How to accept date time combination in shell scripting?
body: <p>I want to accept date time value from passing parameters through user and wants to validate that in shell script. How I can do that, I have tried in following way but failed:</p>
  
  <pre><code>./program.sh 12-10:12:11     (In this 12 is date and other is time)
  </code></pre>
  
  <p>I am passing this as parameter and accepting it in shell script</p>
  
  <pre><code>dtime=$1
  
  if ! [ "`date '+%d-%H:%M:%S' -d $dtime 2&gt;/dev/null`" = "$dtime" ]
  then
  echo $dtime is NOT a valid date format, use the d-H:M:S format
  exit 0
  fi
  
  echo $dtime
  </code></pre>
  
  <p>But it's showing date is not valid.</p>