6

We need to get client system date and time format. At present in our application we 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 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:

  • I am looking for java script or jQuery to get the client system date and time format. My application is developed in .net using c# language. – Sambasiva Rao Jul 29 '15 at 13:41
  • Use moment.js to format time and dates. Best one out there. http://momentjs.com - But you can't get the settings from the PC, you can only guess what their local string will look like with Moment.js – somethinghere Jul 29 '15 at 14:34
  • @somethinghere But which format string will the OP use? That's what the question is, how to know the format in the dialog displayed – Ruan Mendes Jul 29 '15 at 14:36
  • 1
    @JuanMendes _You can't_. Since its an option in the **system**, the only thing you can do a well educated guess. This is the closest useful thing: http://momentjs.com/docs/#/localized-formats – somethinghere Jul 29 '15 at 14:38
  • @somethinghere So there is not a feature in the HTML (or similar) standard to allow for reading the date and time formats from the system? Seems like an oversight that they should implement then. – Liggliluff Apr 24 '20 at 01:55

1 Answers1

0

Possibly a duplicate of this question, you can use the first answer with confidence.

Paul WWJD
  • 133
  • 1
  • 1
  • 11