I have a data in my input text example: 07/22/2013 17:32
and I would like convert in timestamp for inset in my database how can i do?
Myabe the function is mktime
but I don't know how use it.
I'm waiting for help thank you very much
I have a data in my input text example: 07/22/2013 17:32
and I would like convert in timestamp for inset in my database how can i do?
Myabe the function is mktime
but I don't know how use it.
I'm waiting for help thank you very much
Use strtotime() like,
echo $timestamp=strtotime('07/22/2013 17:32');
Possible Duplicate of How to convert date to timestamp in PHP?
You can use PHP's strtotime()
$timestamp = strtotime('07/22/2013 17:32');
Most other answers are suggesting doing it in PHP with strtotime, but that's a silly option. It'll involve at least TWO format conversion (string -> int -> string), and there's also the danger of multiple timezone conversions coming into play and mangling your date before it ever gets saved into the table.
You can do it in MySQL directly, as a single string->native conversion:
INSERT INTO foo (datetimefield)
VALUES (STR_TO_DATE('07/22/2013 17:32', '%m/%d/%Y %H:%i'));
Ref: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_str-to-date