Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 11-18-2020, 12:54 PM
Kyttias's Avatar
Kyttias Kyttias is offline
Premium Member
 
Join Date: Jan 2014
Posts: 857
Gender: Unknown/Other
Credits: 90,987
Kyttias is on a distinguished road
Default

Usually hosting providers can't or won't change the entire server's timezone, as its usually shared hosting, and they'd rather it be local to timezone the server is physically in.

You can change the default time zone for use in particular code on a particular page but don't expect it to carry between pages without specifically making sure its set. (And, of course, this makes the code local to whatever YOU set it to be, not whatever the timezone it currently is for any viewer, so it'll be off for anyone who doesn't share your timezone. Dynamically getting the appropriate timezone is not quite possible without a bit of hackery, which users will always be able to find ways around, anyway.)

But if it helps your mental math to have things based around your own understanding of what time it is, I don't blame you!

Since you're wanting to display code between particular hours, it's worth noting that hours can be checked between midnight 0000 and the minute just before midnight 2359 -- military time. I'm not sure what exactly you're up to, but I hope this can help!

PHP Code:
date_default_timezone_set('America/New_York');
// echo date('Y-m-d H:i:s');

$currentTime date('Hi');
$breakfastStart "0200"$breakfastEnd "1129";
$lunchStart "1130"$lunchEnd "1559";
$dinnerStart "1600"$dinnerEnd "2129";
$lateStart "2130"$lateEnd "0159";

if( 
$currentTime >= $breakfastStart && $currentTime <= $breakfastEnd ){ 
  
/*BREAKFAST*/
    
$timefor 'Breakfast';
} elseif( 
$currentTime >= $lunchStart && $currentTime <= $lunchEnd ){ 
  
/*LUNCH*/
    
$timefor 'Lunch';
} elseif( 
$currentTime >= $dinnerStart && $currentTime <= $dinnerEnd ){ 
  
/*DINNER*/
    
$timefor 'Dinner';
} else { 
  
/*LATE NIGHT SNACK*/
    
$timefor 'Late Night';

Just know that it won't necessarily make sense to everyone viewing it because they won't be in the same time you are. While you're eating breakfast, they could be eating dinner. Even though its dinner time for them in the real world, on your website it's breakfast time because it is where you are. Hope that makes sense!
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it.
Reply With Quote
 

Tags
slashes, stripslashes, time, timezone, zone


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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 04:45 AM.

Currently Active Users: 326 (0 members and 326 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636