vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   vb function to parse timezones (https://vborg.vbsupport.ru/showthread.php?t=276425)

souperman 01-04-2012 03:32 AM

vb function to parse timezones
 
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.

Code:

// 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.


All times are GMT. The time now is 08:01 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01018 seconds
  • Memory Usage 1,711KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete