php - Adding date and time variables and getting unix timestamp
I foolishly thought you could just add the two and somehow magically get away with doing it the following way:
$time = mysql_real_escape_string(stripslashes($_POST['time']));
$date = mysql_real_escape_string(stripslashes($_POST['date']))." ".$time;
$date = strtotime($date);
Obviously there is no way this would work. Basically, I have two fields, one where the user enters in the date and another for time. I need my timestamp to reflect both inputs. Any ideas on how this can be done?
EDIT: For example: I input 09/04/2013 for the date and 7:25 for the time and got: 1378297500 which equals to Wed, 04 Sep 2013 12:25:00 GMT
Answer
Solution:
If you run this code:
You will get:
If you're getting your date & time in
GMT
then set timezone accordingly before callingstrtotime
like this: