I was wondering... how does the date function on this forum work with the user inputted timezones?? I cannot seem to find it in the source... would someone be able to tell me what file to look in? Or even better just tell me how it works! lol
Thanks in advanced...
~Pat
Question about how....
Forum rules
Discussion of general topics related to the new release and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Discussion of general topics related to the new release and its place in the world. Don't discuss new features, report bugs, ask for support, et cetera. Don't use this to spam for other boards or attack those boards!
Re: Question about how....
Without looking at the code I'd imagine that the value you choose for hours ahead (positive) of GMT and behind (negative) can be used in a simple math equation.
Since the time format is the unix one measured in seconds since the unix epoch (1st January 1970 iirc) then the current time can be adjust by adding the time difference in seconds.
For example, say you are 6 hours ahead of GMT which the current time is measured in, then the time is just the current time + 6 * 3600 where the 3600 is an hour in seconds, this would work for negative values too since current time + -6 * 3600 would work out the time 6 hours ago.
I'll have a quick look a bit later if no one else has confirmed/corrected this
Since the time format is the unix one measured in seconds since the unix epoch (1st January 1970 iirc) then the current time can be adjust by adding the time difference in seconds.
For example, say you are 6 hours ahead of GMT which the current time is measured in, then the time is just the current time + 6 * 3600 where the 3600 is an hour in seconds, this would work for negative values too since current time + -6 * 3600 would work out the time 6 hours ago.
I'll have a quick look a bit later if no one else has confirmed/corrected this
Images in sigs! please.
Re: Question about how....
Yea, i figured it out about 20 minutes after posting that hehehe...
Heres what i did:
To make it "user inputable" you would need to do something like:
Heres what i did:
Code: Select all
<?php
Where the \ n's are, remove the space from between them.
echo gmdate('M d Y g:i', gmdate('U') + (-5 * 3600)) , "\ n";
?>
Code: Select all
<?php
// &tz being a var, that is the timezone from -13 to +13
echo gmdate('M d Y g:i', gmdate('U') + (&tz * 3600)) , "\ n";
?>
Re: Question about how....
Hehe.
This is the function i use:
its pretty simple. But this one also take into account day light savings...
This is the function i use:
Code: Select all
function generate_date($dateformat, $timestamp, $tz)
{
if( date('I', $timestamp) )
{
$tz = $tz + 1;
}
return gmdate ($dateformat, ($timestamp + ($tz * 3600)));
}