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?

4
  • jQuery API has virtually no string methods other than $.trim() since no real need to wrap native javascript methods Commented Jun 25, 2012 at 4: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? Commented Jun 25, 2012 at 4:43
  • 2
    I am trying to format a date and other strings too. How could i achieve that? Commented Jun 25, 2012 at 5:03
  • Check this question out, just use javascript for this one Commented Jun 25, 2012 at 5:12

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.