I found this function on the php-manual “date”.
<?php
// Converts a unix timestamp to iCal format (UTC) - if no timezone is
// specified then it presumes the uStamp is already in UTC format.
// tzone must be in decimal such as 1hr 45mins would be 1.75, behind
// times should be represented as negative decimals 10hours behind
// would be -10
function unixToiCal($uStamp = 0, $tzone = 0.0) {
$uStampUTC = $uStamp + ($tzone * 3600);
$stamp = date("Ymd\THis\Z", $uStampUTC);
return $stamp;
}
?>
I have a variable like $event_time[0] that holds a timeformat like this 14:00 which would be 2pm. How can I convert this timeformat so that is decimal to pass it along to the unixToiCal() function above?
Thanks for your response.
Update:
Well, it seems like I’m completely confused. Thanks guys for clearing things up. Didn’t really get what the second param of the function was for. I’m from Austria, so the UTC offset should be +2 hours, right.
There is another question I have with the strtotime() method.
I have two variables … $time and $date … the problem I have with this is that $date already is a timestamp like 1347667200 and $time is a “string” (i guess) 11:00 or 14:00.
How can I combine those two values two a timestamp that represents the exact date and the time?
Nice to see that my post helped you further!
The function you’re working with needs a Unix time:
Therefore a time value alone doesn’t help you further, you need a date component too, otherwise you can’t calculate the unix time.
Here’s an example how to convert something to a unix time in php:
Update:
You can add a time value to a unix time in php like this: