vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   unixtime and timezone differences? (https://vborg.vbsupport.ru/showthread.php?t=193820)

Antivirus 10-17-2008 12:44 AM

unixtime and timezone differences?
 
When displaying a date to a user, I know vbdate() will offset according to a user's timezone, however what would I use when I want to offset a unix timestamp according to the user's timezone within the execution of a script?

Dismounted 10-17-2008 10:01 AM

Do you know the user's timezone in your custom script? If so - you could just add the seconds on to the timestamp before formatting it. (e.g. user with +2.5 hours = TIMESTAMP + (2.5*60))

Antivirus 10-17-2008 05:23 PM

I suppose I could gather the user's timezone difference like this:

$tzdiff = $vbulletin->userinfo['timezoneoffset']

then either increase or decrease the unixtimestamp appropriately, however I would have figured that vbulletin has a function already set up to handle something like this.

I looked all through the API and couldn't find one that handled unixtime, only display time. This is somewhat surprising considering the fact that `dateline` is is used so often in post, thread, user tables etc...

Dismounted 10-18-2008 10:23 AM

When dates are displayed, they are run through vbdate(), meaning all offsets are already handled. The "stored" Unix timestamp is always UTC.

Antivirus 11-07-2008 03:09 AM

correct - vbdate() handles display time, however I was expecting a function to handle just the unixtime. The code you provided above is simple enough, I will just use that and it should suffice - thanks again Dismounted!

Antivirus 11-24-2008 12:32 PM

the reason i am trying to offset the timestamp is because I am attempting to write a calendar search modification, and the events will need to be searched for using unixtime, as offest to the user's timesone.


All times are GMT. The time now is 04:59 PM.

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.01192 seconds
  • Memory Usage 1,709KB
  • 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)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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