0

Hi I am using Jquery's DateTimePicker plugin in my ASP.Net we site. I want to have culture specific date format for my date time picker and where ever date is displayed from JavaScript should also be culture specific. How can we read culture/ regional settings in JavaScript. Also I need both Date and Time.

My Code

 $('#datetimepicker_mask1').datetimepicker({
   **format: 'd/m/Y H:i'**, onSelectTime: function (dp, $input) {}});

As I am harcoding the date format of datetimepicker, I want this format to be dynamic, as date time settings of the system where the site is being viewed

V.B
  • 1,191
  • 7
  • 29
  • 55
  • Are you talking about [`new Date().toLocaleString();`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString) ? – Vedant Terkar Jul 28 '14 at 06:09
  • can you please elaborate what is culture specific? Also show us your jquery datepickere code . – Bhushan Kawadkar Jul 28 '14 at 06:09

1 Answers1

0

The Date() object will get you the client time

var now=new Date();
alert(now.toLocaleString());

JS and jQuery don't have a built in format function. To format it differently use a function like format():

var now=new Date();    
alert( now.format("dd/mm/yy h:MM:ss TT") );

For more deatils of formate() visit here.

You can also

AmanVirdi
  • 1,667
  • 2
  • 22
  • 32