vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Variable value based on time of day (https://vborg.vbsupport.ru/showthread.php?t=103455)

pran 12-21-2005 04:21 PM

Variable value based on time of day
 
I have a variable that I want to change based on the time of day. For example, it would have a specific value from 12:00mn to 7:00am and another value from 7:00am to 12:00mn, and so on and so forth. How do I do this?

noppid 12-21-2005 05:07 PM

PHP Code:

$my_date intval(date("H"));

if( 
$my_date >= && $my_date <= 6)
{
    
// do stuff for midnight to 7am
}
if( 
$my_date >= && $my_date <= 23)
{
    
// do stuff for 7am to midnight


something like that maybe?

pran 12-22-2005 12:11 PM

Can this go inside the template or the PHP files? How do I get the variable from the PHP to the template? Thanks!

merk 12-22-2005 08:27 PM

You can put it in global_start and it will be available in almost all templates.

pran 12-22-2005 09:22 PM

<span style="text-decoration: line-through">Thanks! How do you now display this variable in the template?</span>Never mind, I used template conditionals instead. Thanks!

merk 12-22-2005 09:36 PM

Well, if for example the code you put into global_start looked like

PHP Code:

$my_date intval(date("H")); 

if( 
$my_date >= && $my_date <= 6

    
$coolvariable "Its between midnight and 7am"

if( 
$my_date >= && $my_date <= 23

    
$coolvariable "Its between 7 am and midnight";


You would just simply put $coolvariable in a template, for example, navbar.

pran 12-22-2005 09:46 PM

I couldn't get to display it inside a script tag by using:
PHP Code:

<?php print $coolvariable?>


merk 12-22-2005 10:03 PM

nonono, just use $coolvariable inside templates. (by itself)


All times are GMT. The time now is 10:28 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.01125 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
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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