Rene A <Rene@nospam-Nospamwrote:
I want to go out of a function when the local time is
not in 1:00 am / 6:00 am
im using the folowing code :
if ((DateTime.Now < DateTime.Parse("01:00:00")) && (DateTime.Now >
DateTime.Parse("06:00:00")))
{
Return;
}
How could it ever be before 1am *and* after 6am at the same time?
But it dont work, anyone a tip /id ?
Here's a simpler version:
DateTime now = DateTime.Now;
if (now.Hour < 1 || now.Hour >= 6)
{
return;
}
(That will still exit if it's exactly 6am, but I suspect that's
probably okay for you.)
--
Jon Skeet - <sk***@pobox.com>
Web site:
http://www.pobox.com/~skeet
Blog:
http://www.msmvps.com/jon.skeet
C# in Depth:
http://csharpindepth.com