vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   formatting time outside of vb based on offset (https://vborg.vbsupport.ru/showthread.php?t=65468)

sde 05-24-2004 04:00 AM

formatting time outside of vb based on offset
 
I want to make a new page which shows news, .. however I would like to format the time from my queries based on the offset the users put in their profile.

take this code for example:
PHP Code:

<?
$bbuserinfo[tzoffset]=-7;
$result = mysql_query("select title,body,unix_timestamp(time) as time from news order by time desc");
?>

how do i incorporate the tzoffset into my query to reflect the local time for the user viewing the news?

my time field is stored as a datetime type, .. i can change it to integer14 and store the unix timestamp if that is necessary.

thanks

Boofo 05-24-2004 04:31 AM

Here's what I did for my users online today part of forumhome and it seems to work great for each user's time offset.

PHP Code:

$timestamp vbmktime(000vbdate('m'TIMENOWfalsefalse), vbdate('d'TIMENOWfalsefalse), vbdate('Y'TIMENOWfalsefalse)); 

Then set up your query something like this:

PHP Code:

<? 
$result = mysql_query("select title,body from news WHERE dateline >= $timestamp order by dateline desc"); 
?>

The $timestamp will get each user's time according to their offset.

sde 05-24-2004 05:08 AM

thanks a lot boofoo =) your help is much appreciated!

sde 05-24-2004 05:15 AM

err wait, .. that does help me figure out how to display the user's current time .. and query against that, .. but when i display my news, it will always display the same news articles. there will be no 'where' clause.

when i loop through the news, i need to display the time as the user's current time.

.. heh and as i think about it, would i do something like this?
PHP Code:

<?
$result = mysql_query("select title,body,unix_timestamp(time) as time from news order by time desc limit 10");
while($row = mysql_fetch_array($result)){
  // does this next line convert the news article time to the user's timezone?
   $timestamp = vbmktime(0, 0, 0, vbdate('m', $row[time], false, false), vbdate('d', $row[time], false, false), vbdate('Y', $row[time], false, false)); 
}
?>

thanks

sde 05-24-2004 05:29 AM

=/ now that i tried it, i can't figure out where vbmktime() is located.

i'm including global.php, do i need to include something else for that function?

Boofo 05-24-2004 05:43 AM

I'm sorry, I forgot to add this:

PHP Code:

require_once('./includes/functions_misc.php'); 

;)


All times are GMT. The time now is 02:11 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.01870 seconds
  • Memory Usage 1,725KB
  • 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
  • (5)bbcode_php_printable
  • (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