php - Adding date and time variables and getting unix timestamp -


i foolishly thought add 2 , somehow magically away doing following way:

$time = mysql_real_escape_string(stripslashes($_post['time'])); $date = mysql_real_escape_string(stripslashes($_post['date']))." ".$time; $date = strtotime($date); 

obviously there no way work. basically, have 2 fields, 1 user enters in date , time. need timestamp reflect both inputs. ideas on how can done?

edit: example: input 09/04/2013 date , 7:25 time , got: 1378297500 equals wed, 04 sep 2013 12:25:00 gmt

if run code:

date_default_timezone_set('cst6cdt'); $dt = strtotime('09/04/2013 7:25'); echo $dt . " - " . gmdate('r', $dt); 

you get:

1378279500 - wed, 04 sep 2013 12:25:00 +0000 

if you're getting date & time in gmt set timezone accordingly before calling strtotime this:

date_default_timezone_set('gmt'); 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -