PDA

View Full Version : vb function to parse timezones


souperman
01-04-2012, 03:32 AM
Is there's a vb function that parses a timestamp into the correct timezone based on the user's timezone setting?

Like a function that displays that displays the correct time and another function that grabs a user-entered time-stamp and converts it to the server time. Pretty much a function that can display the proper time based on the user's timezone setting and another one that does the opposite (converters the user's time to the server time).

kh99
01-04-2012, 04:02 AM
Here the part of the code that displays post date and time. $post['dateline'] is a timestamp, and $post['postdate'] and $post['posttime'] are the date and time that are displayed.

// format date/time
$this->post['postdate'] = vbdate($this->registry->options['dateformat'], $this->post['dateline'], true);
$this->post['posttime'] = vbdate($this->registry->options['timeformat'], $this->post['dateline']);


I don't know if there's a vb function to go the other way (I can't think of anywhere where a user enters a date and time), but there's a php function called strtotime: http://us2.php.net/manual/en/function.strtotime.php . You'd have to figure out how to apply the current user's timezone (and maybe handle daylight savings time). Maybe you could look at the code for vbdate and figure out how to go in the other direction (unless someone else knows a better way).

souperman
01-04-2012, 08:11 PM
I figured as much for the second function. Probably have to write my own. Thanks kh99.