Current date
-
Hello friends, I need your help in this issue. Am working on exam system using asp.net. There is a feature I would like to apply. On the onload event of the welcome page, the application should check the devices' date and compare it with the current date. If the devices' date is not same as current date, the person should be redirected to a warning page with a warning message the device date is not accurate. Please set time and date. Example, if the current date is 10-09-2014 and the devices' date is 09-09-2014, that means the devices' date is not accurate. I really need this because the date and time student logged in will be auto-captured and saved to database for officials' use. I have googled alot but couldn't found any match and am not even sure if am using the right keywords. Please, any idea on how to play around this will be highly appreciated.
I think that you should not use the client date instead use your server date on student login so you would face no problem as the server date appears on the screen.
Help people,so poeple can help you.
-
I think that you should not use the client date instead use your server date on student login so you would face no problem as the server date appears on the screen.
Help people,so poeple can help you.
Thanks. But, how can I capture the server date?
-
Thanks. But, how can I capture the server date?
easily. When a student logged in you save getdate() which would return the database time. or you pass the value of DateTime.Now for the web server time. and you can do the same for the time you want to send it with the response.
Help people,so poeple can help you.
-
easily. When a student logged in you save getdate() which would return the database time. or you pass the value of DateTime.Now for the web server time. and you can do the same for the time you want to send it with the response.
Help people,so poeple can help you.
Thanks I really appreciate your response. But, when if I use DateTime.Now, is the client device date that will be captured and the date might not be current. This is what am trying to avoid. To be more specific, assuming today's date now which is 11/09/2014 and maybe the student might not have his device date set(assuming the students' device date is 10/08/2014 instead of 11/09/2014, I want to compare the current date with the device date then if match, student should be allowed else should be prompt for system date correction. Anyway? Please.
-
Thanks I really appreciate your response. But, when if I use DateTime.Now, is the client device date that will be captured and the date might not be current. This is what am trying to avoid. To be more specific, assuming today's date now which is 11/09/2014 and maybe the student might not have his device date set(assuming the students' device date is 10/08/2014 instead of 11/09/2014, I want to compare the current date with the device date then if match, student should be allowed else should be prompt for system date correction. Anyway? Please.
Calling
DateTime.Now
from server-side code will capture the current date and time on the server. The client's date/time settings will have no effect.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Calling
DateTime.Now
from server-side code will capture the current date and time on the server. The client's date/time settings will have no effect.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
Ok. Thanks. But, please how can I call the DateTime.Now on the server side?
-
Ok. Thanks. But, please how can I call the DateTime.Now on the server side?
Just add it to the code that's saving the details to the database:
yourInsertCommand.Parameters.AddWithValue("@StartDate", DateTime.Now);
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
Just add it to the code that's saving the details to the database:
yourInsertCommand.Parameters.AddWithValue("@StartDate", DateTime.Now);
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
I reset my systems' date to incorrect date and tried what you suggested. But, it was the system's date which is inaccurate it captured. Or will this before solve when the site has been host?
-
Just add it to the code that's saving the details to the database:
yourInsertCommand.Parameters.AddWithValue("@StartDate", DateTime.Now);
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
I reset my systems' date to incorrect date and tried what you suggested. But, it was the system's date which is inaccurate it captured. Or will this be solve when the site has been host?
-
I reset my systems' date to incorrect date and tried what you suggested. But, it was the system's date which is inaccurate it captured. Or will this before solve when the site has been host?
If you're testing the site locally, the client and server will be the same machine. If you change the client's date, then you're also changing the server's date.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer