Click here to Skip to main content
15,916,692 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
When the admin will set the starting time and ending time.lets see the example
Now the staring time is 19/05/2015 11.00AM and the ending time is 20/05/2015 6.00pm
its will be the time period.while the user will logon below time peroid else block the login process.Can you suggest me how to achive this.
Posted

1 solution

Quote:
DateTime start = new DateTime(2015,05,19,11,00,00,00);
DateTime end = new DateTime(2015,05,20,6,00,00,00);
TimeSpan timespan;
timespan = end - start;
double timeDifference = timespan.TotalHours;
Console.WriteLine("Time Difference is :" + timeDifference);
Console.ReadKey();
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 19-May-15 1:41am    
5ed.
—SA
Pankit Patel 19-May-15 1:50am    
sorry I am not getting what u want to say
Sergey Alexandrovich Kryukov 19-May-15 1:59am    
I voted maximum vote (5) for you answer.
—SA
Pankit Patel 19-May-15 2:01am    
ok..thanks
venkatesh@India 19-May-15 2:57am    
Thanks@Pankit Patel .That code working fine and while how to compare the two dates.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900