PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 14th, 2004, 08:36 AM
tanerius tanerius is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 1 tanerius User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
time difference problem

Hello,
I would like to ask can any 1 help me regarding the problems i have sith time difference. Namely, my host is in the states (ET - NY, NJ etc.) and im in europe (GMT+2 Greece).

Is there a way to detect the clients time and ifso how??
Plus how do i increment the time to the corret timezone (gmt+2) when i get it from the server?

thank you
tanerius

Reply With Quote
  #2  
Old October 14th, 2004, 11:14 AM
Viper_SB's Avatar
Viper_SB Viper_SB is offline
Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: Canada
Posts: 331 Viper_SB User rank is Private First Class (20 - 50 Reputation Level)Viper_SB User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 4 h 53 m 7 sec
Reputation Power: 6
For PHP look up gmdate To get the client time I believe you have to use Javascript.

Reply With Quote
  #3  
Old October 17th, 2004, 01:34 PM
m3rajk m3rajk is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 24 m3rajk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
incorrect. you would need a client side script and cookie, or use the db and have the client SELECT their time to get theri local time.

gmdate() is the way to format time

this is why phpbb asks the user for their timezone.

Reply With Quote
  #4  
Old October 17th, 2004, 10:12 PM
Viper_SB's Avatar
Viper_SB Viper_SB is offline
Moderator
Click here for more information.
 
Join Date: Oct 2003
Location: Canada
Posts: 331 Viper_SB User rank is Private First Class (20 - 50 Reputation Level)Viper_SB User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 1 Day 4 h 53 m 7 sec
Reputation Power: 6
I didn't space it properly With gmdate you use it to get the GMT time then you convert it for your user to whatever they have specified.
If you want the client's time automaticly you use Javascript and pass it via a form or a url. But the easiest is like he said get them to set there timezone.

Reply With Quote
  #5  
Old October 17th, 2004, 11:05 PM
m3rajk m3rajk is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 24 m3rajk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
no problem.i used this in a site i scripted.

excerpt lines from a script.....
PHP Code:
<?php
 
/* some stuff */
 
$utds='m/d/Y H:i:s'$gmtos='-5'$access=$vis# set default time display/gmt offset/access (guest settings)
 /* some stuff accessing the db  and possibly resetting those based on cookies*/
 /* other parts of the script */
 
function mkfrmlst($foruminf$utds$gmtos){ // make a forum into a table string for display
   
$lauth=$foruminf['username']; $lpt=$foruminf['UNIX_TIMESTAMP(lpt)']; # who/when of lst pst
   
if($lpt==0){ $lpt='No Posts'$lauth='No Posts'; } # no posts ever
   
else{ $lpt=gmdate($utds, ($lpt+($gmtos*60*60))); } # change to user's time format/zone
   
$tblln="        <tr><td class=\"mfld\"><span class=\"frmttl\"><a href=\"{$_SERVER['PHP_SELF']}?fid={$foruminf['fid']}\">{$foruminf['title']}
 </a></span><br /><span class=\"frmblrb\">{$foruminf['blurb']}</span></td><td class=\"mfld\">{$foruminf['threads']}</td><td class=\"mfld\">$lau
 th</td><td class=\"mfld\">$lpt</td></tr>\n"
# add the row with the forum
   
return $tblln;
 }
 function 
mkthrdlst($thrdinf$utds$gmtos){ # construct actual thread listing
   
$lpt=gmdate($utds, ($thrdinf['UNIX_TIMESTAMP(thrd.lpt)']+($gmtos*60*60))); # set time
   
$lock='<img alt="unlocked" src="sitepics/unlocked.png" title="unlocked">'; if($thrdinf['locked']){ $lock='<img alt="locked" src="sitepics/lo
 cked.png" title="locked thread" />'
; } # set locked
   
$goto=''$posts=$thrdinf['amt_posts']; if($posts>20){ $goto="<br />Go To Page:<a href=\"{$_SERVER['PHP_SELF']}?tid={$thrdinf['tid']}&pa
 ge=1\">1</a>"
$pg=2; while(($posts=$posts-20)>20){ $goto.=", <a href=\"{$_SERVER['PHP_SELF']}?tid={$thrdinf['tid']}&page=$pg\">$pg</a>"
 
$pg++; } if($posts>0){ $goto.=", <a href=\"{$_SERVER['PHP_SELF']}?tid={$thrdinf['tid']}&page=$pg\">$pg</a>"; }} # set goto
   
$thrd="         <tr><td class=\"right\">$lock</td><td class=\"tcs\"><a href=\"{$_SERVER['PHP_SELF']}?tid={$thrdinf['tid']}\">{$thrdinf['sub'
 ]}</a>$goto</td><td class=\"tpcs\">{$thrdinf['amt_posts']}</td><td class=\"tcs\">{$thrdinf['auth']}</td><td class=\"tcs\">{$thrdinf['lpa']}</t
 d><td class=\"ttcs\">$lpt</td></tr>\n"

   return 
$thrd;
 }
 
?>


using the passed time display and gmt offset, the timestamp is made to be local to the user

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > time difference problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT