tags:

views:

46

answers:

1

I would like to calculate a timestamp based on the input date. I would like to calculate it from the user input (something like 12/12/2011) I guess I need a function that changes the format to something readable for php and then calculate timestamp for this date. Maybe I should use strtotime() function? Any ideas will be appreciated.

  $date = $_POST['date'];

 <input type="text" name="date" value="">
+2  A: 

Indeed you can use strtotime:

if (($timestamp = strtotime($date)) === false) {
  echo "not good";
} else {
  echo $timestamp;
}

Check the php documentation.

DuoSRX