1

How to have the output of my JSON Date value as follows in JQuery? '11/25/2011 10:43:45 AM'

arlen
  • 1,065
  • 1
  • 16
  • 31
  • Datetime format of SQL Server – arlen Nov 25 '11 at 18:46
  • Which is ....... and what language are you using to get from SQL to the browser ? there are lots of ways to skin a cat – Manse Nov 25 '11 at 18:46
  • There is no inbuilt method in jQuery to change the format of a date - but there are in SQL / MySQL / PHP / .NET / Java ... ie they are more suited to change the format of a date .... (im not saying it cant be done in JavaScript) – Manse Nov 25 '11 at 18:48
  • like Date.Now in Asp.net and I want to format it like '11/25/2011 10:43:45 AM' – arlen Nov 25 '11 at 18:49
  • I dont use SQL server and i dont use Asp.net - just **please** update your question with the format of the date you want to translate !!! – Manse Nov 25 '11 at 18:50

2 Answers2

2

You could try datejs - http://www.datejs.com/

You can see a full list of the formats it provides here - http://code.google.com/p/datejs/wiki/FormatSpecifiers

ipr101
  • 24,096
  • 8
  • 59
  • 61
  • I will, I like to use the client side resources than the server side, but for now I didn't want to use external JS in my project and use the server side formatting instead. – arlen Nov 25 '11 at 19:06
1

If you are not using the date as a date type, but for display I tend to just get the date into the string format I like on JSON source and pass it to the client like that, ie: rather than let the date be serialized into '/Date(1224043200000)/' I pass DateTime.Now.ToString().

If you can't do that How to Format a JSON date might help?

Community
  • 1
  • 1
Neil Thompson
  • 6,356
  • 2
  • 30
  • 53