0

I have to display the date in jsp 12:30 PM 12TH JANUARY 2000 in this format .How can i format the current date in the above format in JavaScript or using jQuery UI.

var currentDate = new Date();
currentDate.toString("hh:MM dS MMMM yyyy")

I have tried the above code but it's not working.

Sirko
  • 72,589
  • 19
  • 149
  • 183
user2210071
  • 203
  • 3
  • 6
  • 11

2 Answers2

0

jquery date format is separate plugin.U need to add explicitly using <script> tag.

Formatting using javascript

<script>
    $.format.date("2009-12-18 10:54:50.546", "dd/MM/yyyy");
    </script>

E.g.,

<script>
document.write($.format.date("2009-12-18 10:54:50.546", "Test: dd/MM/yyyy"));
document.write($.format.date("Wed Jan 13 10:43:41 CET 2010", "dd~MM~yyyy"));
</script>

See here

Pablo Cantero
  • 6,239
  • 4
  • 33
  • 44
Vignesh Vino
  • 1,242
  • 4
  • 25
  • 50
0

Strange as it seems, Javascript doesn't have a built-in function or method that lets you specify the date/time formatting.

But you can use something like this: https://github.com/samsonjs/strftime

Gato
  • 671
  • 5
  • 15