MyBB Community Forums

Full Version: Formatting dateline for user timezone
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Alright, simple question (I think/hope), I have a dateline and I want to output it in a readable format for users. Easy, though I don't know each user's timezone so for now I just have it outputting in GMT. I'm sure there's a function or something to convert the time and output it based on user timezone settings, but I can't find it. Help?


Thanks Big Grin
my_date($format, $stamp, $offset, $ty, $adodb)

@param string A date format according to PHP's date structure.
* @param int The unix timestamp the date should be generated for.
* @param int The offset in hours that should be applied to times. (timezones)
* @param int Whether or not to use today/yesterday formatting.
* @param boolean Whether or not to use the adodb time class for < 1970 or > 2038 times
* @return string The formatted timestamp.
*/
Ah thanks G33K, but I still have the problem of formatting it based on the user's timezone; I don't know where to get that.
The logged in user's timezone is accessible through:

$mybb->user['timezone']+$mybb->user['dst']

This takes in to account both the timezone and the dst correction. Use this as the offset in the function.
Alright thanks, appreciated the help! +rep Smile