echo $_POST['time']."<br/>";
echo $_POST['day']."<br/>";
echo $_POST['year']."<br/>";
echo $_POST['month']."<br/>";
I have value store like this now I want to create a timestamp from these value. How to do that in PHP? Thanks in advance
Returns the current time measured in the number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT). Note: Unix timestamps do not contain any information with regards to any local timezone.
The strtotime() function parses an English textual datetime into a Unix timestamp (the number of seconds since January 1 1970 00:00:00 GMT).
The strtotime() function is a built-in function in PHP which is used to convert an English textual date-time description to a UNIX timestamp. The function accepts a string parameter in English which represents the description of date-time. For e.g., “now” refers to the current date in English date-time description.
You can use mktime(). Depending on the format of $_POST['time']
, you split it into hour/min/sec and then use
$timestamp = mktime($hour, $min, $sec, $month, $day, $year)
echo mktime(0,0,0,$_POST['month'],$_POST['day'],$_POST['year']);
I don't know in what format your time is, so, you probably need to explode() it and then put the values into the three first parameters of mktime() like:
$_POST['time'] = '8:56';
$time = explode(':',$_POST['time']);
echo mktime($time[0],$time[1],0,$_POST['month'],$_POST['day'],$_POST['year']);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With