1

I want to format a string before assigning it to a label's text property in jquery. I want something as follows (code is in C#),

string.Format("{0:MM/dd/yyyy}", m.hire_dt);

I am trying to format a date and other strings too. How could i achieve that?

Javed Ahmed
  • 406
  • 5
  • 21
  • jQuery API has virtually no string methods other than $.trim() since no real need to wrap native javascript methods – charlietfl Jun 25 '12 at 04:37
  • 1
    What exactly are you trying to do? Do you just want to format a date, or do you want to try to format other things too? – gen_Eric Jun 25 '12 at 04:43
  • 2
    I am trying to format a date and other strings too. How could i achieve that? – Javed Ahmed Jun 25 '12 at 05:03
  • Check [this](http://stackoverflow.com/q/1056728/463065) question out, just use javascript for this one – Trufa Jun 25 '12 at 05:12

1 Answers1

2

If you are trying to format a date string, you can try the answer to this question. It's basically suggests that you need to concatenate the different date components.

If you are using jquery UI and you need the built-in datetime picker, there's a formatDate function wherein you can specify which format you prefer.

For general date manipulation, it is best to use Date.js.

Community
  • 1
  • 1
Alex R.
  • 4,664
  • 4
  • 30
  • 40