473,513 Members | 4,001 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

compare time for multiple cases

31 New Member
how can i apply the below code for multiple cases? where the cases have different goal time, is it possible? Thank you =)


Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     $currenttime = date("H:i:s");
  3.     $goaltime = "09:12:00";
  4.  
  5.     echo "
  6.     Current time: $currenttime<br>
  7.     Goal time: $goaltime<p>
  8.     ";
  9.  
  10.  
  11.  
  12.     echo "<meta http-equiv= 'refresh' content='1'>";
  13.  
  14.     if ($currenttime >= $goaltime)
  15.     {
  16.     echo "<b>Goal has been reached!</b>";
  17.     echo "<div align=center><img src=\"images/yellow.jpg\" alt=\"bla bla\" ></div>";
  18.     }
  19.  
  20.     else  
  21.     {
  22.     echo "<div align=center><img src=\"images/red.jpg\" alt=\"bla bla\" ></div>";
  23.     echo "Have a nice day!";
  24.     }
  25.     ?>
Oct 19 '12 #1
4 2194
dlite922
1,584 Recognized Expert Top Contributor
if you have multiple goal times, put them into an array.
Oct 19 '12 #2
huda89
31 New Member
why the currenttime does not follow my pc time? how can i change it to follow my pc time?
Oct 22 '12 #3
zmbd
5,501 Recognized Expert Moderator Expert
I don't know php at all so this is a poke in the dark; however, this seems to deal with using the local pc time:
http://php.net/manual/en/function.localtime.php There appears tobe some fairly nice examples and some things to consider when implementing the code.
Oct 22 '12 #4
huda89
31 New Member
dtlite922 + zmbd: Thank you =)
Oct 23 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
1232
by: Gary Smith | last post by:
Hello, We have a set of Access databases that we extract data from into a centralized Oracle database. We have a copy of this database in San Francisco, New York and London. The SF and NY team actually use the same one over the lan. Anyways, we have a date updated field that basically used the form update event to set it to now. Is...
122
5202
by: Einar | last post by:
Hi, I wonder if there is a nice bit twiddling hack to compare a large number of variables? If you first store them in an array, you can do: for (i = 0; i < n; i++) { if (array != value) { /* array differs from value, do something*/
2
20357
by: Guadala Harry | last post by:
After RTFM, I hope I have missed something: I would like to have a switch() statement process multiple input values the same way - but without having multiple case: blocks for multiple input values that need to be processed the same way. For example, please consider the following sample switch block and notice that "other value 1, 2, and 3"...
3
1797
by: muntyanu | last post by:
Hi all, I have datetime field in database. When I am getting records older than specific date that I passed in parameter I can not get records that differs only in Time part of the datetime value. Looks like comparison of Time portion in query failed. I would appreciate any advice Thanks, Roman
3
1987
by: James | last post by:
Hi Guys, Just looking for the best way to compare two times. What I want to do is make sure a time is in between two other times. E.g. If the current time is 14.00 I want to check that it is between 13.30 and 14.30. Would it be best be using the TimeSpan class?
2
3476
by: eddiekwang | last post by:
Hello, I need to store the start and end time of each weekly class into a database. so that people can easily search for classes based on time. for example, someone might want to search all classes that are offered between 9am and 2pm. How can i implement this time field? i don't have a date to store with the hour and minutes. is there and...
2
2505
by: knoxvegas | last post by:
I have a table that will be storing the time I want to compare with the current time of an action. Any help appreciated. I'm new to asp programming.
2
7051
by: lyealain | last post by:
hi.. how do i compare the 2 dates from different textbox>?? let say date A cannot be larger than date B? if larger.. then fail ..thanks
9
2890
by: Mike1961 | last post by:
Hi everyone. Whit JavaScript it's posible compare time inserted into a form ( in the format hh: mm ), with the time of your PC ? If this time is inserted before or less of the time of PC ( or with a specific reference time ) to stop the compilation this form ? Thanks for your attention. Mike
0
2231
by: kishorealla | last post by:
Hello I need to create a web bot/crawler/spider that would go into different web sites and collect data for us and store in a database. The crawler needs to 'READ' the options on a website (either from drop-downs, radio-buttons or check-boxesand) to create some input itself OR use some generic pre-defined words (that we provide it with). For...
0
7270
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7543
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5703
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5102
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4757
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3239
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1612
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
813
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
470
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.