Click here to Skip to main content
15,895,283 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I need to get client system date and time format. At present in my web application (developed in asp.net using C# language) I have requirement when user login into the application they have to see the date and time format as his local PC date and time format setting.

For example, he is accessing the site form the server and then he able to see exact his local system date and time format instead of server format. We tried this approach by using date.toLocaleDateString(), but this is returning the current local system date instead of format. Even date.toLocalDateString() is behaving differently in different browsers.

How do I get exact customize date and time format of client system?
Example: like (dd/MM/yyyy hh:mm, MM/dd/yyyy hh:mm and so on).
What I'm expecting:
http://screencast.com/t/pqFxfFWqTZgX[^]
Posted
Updated 29-Jul-15 4:04am
v4

 
Share this answer
 
There is no function can reveal you the settings of the OS - these are shield from you for security reasons...
As you already spotted the actual value depends on the browser's implementation (however can be controlled via locale and options in modern browsers)...
If you want to give the feel of home while browsing your site use toLocalDateString without extra options and do not afraid, most users do not switch browser just for fun, and if do they will got accustomed to it...
If you want the same display format, then format your string as you wish and left the OS settings alone (anyway you can not get them)...
 
Share this answer
 

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