473,503 Members | 1,858 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Time occurs between two time

I need a function such it returns true when current time occurs
between the parameters.

function checkTime($time1,$time2){
$nowTime=date("H:i:s");

//MY LOGIC IS

if( $time1>$nowTime && $time2<$nowTime)

///

return true;
else
return false;

}

plz guide me the function run.

Aug 3 '07 #1
5 1510
Kesavan wrote:
I need a function such it returns true when current time occurs
between the parameters.

function checkTime($time1,$time2){
$nowTime=date("H:i:s");

//MY LOGIC IS

if( $time1>$nowTime && $time2<$nowTime)

///

return true;
else
return false;

}

plz guide me the function run.
You can't compare times as strings and expect it to work. You need to
first convert them to a numeric value, i.e. unixtime format.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Aug 3 '07 #2
On 03.08.2007 13:37 Jerry Stuckle wrote:
Kesavan wrote:
>I need a function such it returns true when current time occurs
between the parameters.

function checkTime($time1,$time2){
$nowTime=date("H:i:s");

//MY LOGIC IS

if( $time1>$nowTime && $time2<$nowTime)

///

return true;
else
return false;

}

plz guide me the function run.

You can't compare times as strings and expect it to work. You need to
first convert them to a numeric value, i.e. unixtime format.
Times in H:i:s format can be perfectly compared as strings.
--
gosha bine

makrell ~ http://www.tagarga.com/blok/makrell
php done right ;) http://code.google.com/p/pihipi
Aug 3 '07 #3
You can't compare times as strings and expect it to work. You need to
first convert them to a numeric value, i.e. unixtime format.

Times in H:i:s format can be perfectly compared as strings.
yup, currently doing it in a small project I'm working on.

your function:

function checkTime($time1,$time2){
$nowTime=date("H:i:s");
//do validation on $time1 and $time2 to ensure H:i:s format

if( $time1>$nowTime && $time2<$nowTime) {
return true;
}
else {
return false;
}
} // end checkTime
your function, which stripped of validation and exception handling,
looks like it should work (so long as $time1 and $time2 are in H:i:s
format. What's the problem?

Aug 3 '07 #4
Kesavan wrote:
if( $time1>$nowTime && $time2<$nowTime)
return true;
else
return false;
This can be abbreviated as:

return ($time1>$nowTime && $time2<$nowTime);

Whenever you find yourself writing:

if (X) return true;
else return false;

Just write:

return X;

instead.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 43 days, 20:43.]

Command Line Interfaces, Again
http://tobyinkster.co.uk/blog/2007/0...nd-line-again/
Aug 3 '07 #5
Kesavan wrote:
I need a function such it returns true when current time occurs
between the parameters.
Technically speaking, the following function meets the above
specification:

function checkTime () { return TRUE; }

Although I know what you *meant*, it pays to be fairly specific
around here.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 43 days, 20:46.]

Command Line Interfaces, Again
http://tobyinkster.co.uk/blog/2007/0...nd-line-again/
Aug 3 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5199
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
77
4503
by: Charles Law | last post by:
Hi guys I have a time critical process, running on a worker thread. By "time critical", I mean that certain parts of the process must be completed in a specific time frame. The time when the...
1
2505
by: gi75research | last post by:
What should be a very simple function is going terribly wrong, and I don't know why. StartTime and EndTime are table values (formatted like "01:00A" or "02:00P"); DaypartStart and DaypartEnd are...
2
1445
by: Hank | last post by:
Hello, I have researched old topics and have seen this problem discussed but have not seen a complete solution. I check the usage of spoolsv and its using zero CPU time. Then I open a report...
5
5049
by: galsaba | last post by:
How can I find how many time a string appears in a text. Is there a function in access that does it? For example, text: "My name is John Smith, and my wife is Katy Smith" HowMany(text, "Smith")...
5
2474
by: Manish Jain | last post by:
Environment: Windows 2000 Server (SP4), ASP.Net/C# (Framework 1.1) Hardware: PIII @ 700 MHz, 512 MB RAM ----------------------------------------------------------------------------...
7
2608
by: José Joye | last post by:
On all my Windows Services (written in C# and for some of them in MC++), I got from time to time crashes at startup (1 out of 10 startup). It occurs really at the time I click on the "Start...
7
2382
by: J e r | last post by:
I'm a novice using VB .NET . I'm trying to use 2 files to read a line write the line and get the run time error "..exception of type 'System.IO.IOException.....additional information: File...
14
3453
by: Gotisch | last post by:
Hi, we are currently writing an mostly singlethreaded (game)server application in c#. But we are encountering problems with the Garbage Collector: After a certain time but also apparently...
4
2939
by: ahmurad | last post by:
Dear Xperts, In my database table some fault code type records are inserted and the values are like bellows: Error:2/FC:10; 00:15:13 16/03/2009; Error:2/FC:20; 00:15:15 16/03/2009; ...
0
7202
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,...
0
7086
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7460
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...
1
5014
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...
0
4672
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...
0
1512
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 ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
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...

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.