I have a good grasp of the basics of php, i;ve been working with it for about a year or so, but i've stumbled upon some problems while trying to edit timestamps.
I;ve got a script setup with events for people to place bets on, and everything works fine except one little thing.
I have my edit page setup to convert the timestamp to gmdate, and that all works fine, i've got the output of it going to select boxes, to edit the month, year, day, hour and min, but when i submit the data to the database, the strtotime function seems to convert the date, year and month with no problems, but for some reason the hours and mins of the conversion, for example if i select 00 hours and 00 mins for the event, it puts the time as 14:30. No matter what time i select, it always comes out 14:30 different to what im putting in, which is quite a pain to say the least lol The script to add the events is the same, everything works great but the time. I havent had much experience using timestamps, and have read up as much as i can in the php manual, but i cant seem to find anything usefull, so hopefully one of you fine folk will be able to slap me upside da head and tell me what im doing wrong l
Im almost positive its the way im using strtotime to convert the data back to a timestamp. I'm using the variables $day $month $year $hour and $min, and the output from the script is fine, so it has to be in the conversion back to the timestamp.
Also im having to add a day to the actual timestamp, because that isnt working properly either.
Here is the code
The modify function is
function DOmodify() {
global $db,$id,$event,$player1,$player2,$results,$winner,$year,$month,$day,$hour,$min;
$modtime = "$day $month. $year $hour:$min:00";
$newdate = strtotime($modtime);
$realdate = ($newdate+86400);
$db->query("UPDATE bet_events SET event='$event',player1='$player1',player2='$player2',date='$realdate',results='$results',winner='$winner' WHERE bid='$id' LIMIT 1");
betLog("Mod Event ($id)");
watto("Okay, i modified the event. Now i need my beauty sleep. so go away!<br>$event,$player1,$player2,$realdate,$results,$winner,$id") ;}
and the add function is
function DOaddevent() {
global $db,$event,$player1,$player2,$year,$month,$day,$hour,$min;
$moddate = strtotime("$month $day $year $hour $min");
$realdate = ($moddate+86400);
$db->query("insert into bet_events values ('','$event','$player1','$player2','$realdate','','')");
watto('Okay, i added the event. Lets hope we can make some money off these poodoo!') ;
betLog("Add Event ($event)");
}
Its probably something really really simple, but for the life of me i cant work the damn thing out. Any help would be greatly appreciated 🙂