php date time, add variable number of hours to string
$30-250 USD
Concluído
Publicado há aproximadamente 11 anos
$30-250 USD
Pago na entrega
I want to add variable number of hours to a date/time string
it has to work on the whole string so for example:
$Time1 = "2013-01-16 23:31:01";
plus 1 hour would give "2013-01-17 00:31:01";
it also has to fit in with the existing program code, as below
i would lile a sample php script as well so i can test with above strings etc
//-------------------------------------------------------------------------------------
// how string is made up in program
$rmc_time = $rmc_parts [1];
$rmc_date = $rmc_parts [9];
// Turn the RMC timestamp into a nice Mysql timestamp
$time_fix = '20' . $rmc_date [4] . $rmc_date [5] . '-' . $rmc_date [2] . $rmc_date [3] . '-' . $rmc_date [0] . $rmc_date [1] . ' ' . $rmc_time [0] . $rmc_time [1] . ':' . $rmc_time [2] . $rmc_time [3] . ':' . $rmc_time [4] . $rmc_time [5];
//-------------------------------------------------------------------------------------
// later in program
$no_hours_to_add = 1;
if $no_hours_to_add > 0 then
$time_fix = $time_fix + $no_hours_to_add
end
Hello,
Not sure I understand you fully,
but as I understand you need some function which will take first parameter: time in format
$time = "2013-01-16 23:31:01";
and second parmeter:
$number_of_hours
and as a result will return time.
Regards.
Dima
Dear sir, I have over 10 years of experience in Web Development including PHP, Smarty, MySQL, jQuery, etc. Also I am Zend Certified PHP Developer (ZCE). I can help you out with your troubles. Let's do it!