Register Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools
  #1  
Old 17 Oct 2008, 01:44
Antivirus's Avatar
Antivirus Antivirus is offline
 
Join Date: Sep 2004
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?
__________________
Please feel free to PM me about custom work, installations, and upgrades!

Eclipse Records - Streetcult Street Team
Reply With Quote
  #2  
Old 17 Oct 2008, 11:01
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Real name: Hanson
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))
__________________
View My Modifications
29 Releases and Counting... Latest Modification: dmActivityStream - vBookie Integration (4.x)

Please do not PM me to ask for support - please use the relevant thread or forum.
Reply With Quote
  #3  
Old 17 Oct 2008, 18:23
Antivirus's Avatar
Antivirus Antivirus is offline
 
Join Date: Sep 2004
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...
__________________
Please feel free to PM me about custom work, installations, and upgrades!

Eclipse Records - Streetcult Street Team
Reply With Quote
  #4  
Old 18 Oct 2008, 11:23
Dismounted's Avatar
Dismounted Dismounted is offline
 
Join Date: Jun 2005
Real name: Hanson
When dates are displayed, they are run through vbdate(), meaning all offsets are already handled. The "stored" Unix timestamp is always UTC.
__________________
View My Modifications
29 Releases and Counting... Latest Modification: dmActivityStream - vBookie Integration (4.x)

Please do not PM me to ask for support - please use the relevant thread or forum.
Reply With Quote
  #5  
Old 07 Nov 2008, 04:09
Antivirus's Avatar
Antivirus Antivirus is offline
 
Join Date: Sep 2004
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!
__________________
Please feel free to PM me about custom work, installations, and upgrades!

Eclipse Records - Streetcult Street Team
Reply With Quote
  #6  
Old 24 Nov 2008, 13:32
Antivirus's Avatar
Antivirus Antivirus is offline
 
Join Date: Sep 2004
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.
__________________
Please feel free to PM me about custom work, installations, and upgrades!

Eclipse Records - Streetcult Street Team
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Jump


New To Site? Need Help?

All times are GMT. The time now is 03:25.

Layout Options | Width: Wide Color: