1

I had a problem on extjs date. Seem by default it using computer date to create a date. I don't check up my pc and post the date.Then i found it based on American

 M/d/yyyy.

After i change the system regional setting date to d-m-Y.Everthing work fine. So anybody know how extjs get client date format ?

e.g 'YYYY-mm-dd' or 'M/d/yyyy' .

Since i need to parse the format from extjs code to php to mysql date format. I try to find stackoverflow and site but seem not found out,

Hafizan Aziz
  • 269
  • 1
  • 3
  • 13

3 Answers3

1

You can convert date to String when transfer it so that you can set the date format by yourself.

ijse
  • 2,998
  • 1
  • 19
  • 25
  • a bit tricky since you cannot knew which date using format m-d-y or d-m-y.Both are logic on 1-12-2012 or 12-1-2012. unless create a class checking it was a valid date or not.. – Hafizan Aziz Jan 04 '12 at 06:19
  • It is a data object, not a string, so you can convert it to the format string whatever you like. – ijse Jan 05 '12 at 03:12
1

Actually the default format used is 'm/d/y', and you can change the format self, and I don't think so the ext can get the client date format and change the format consistently.

Liping Huang
  • 4,378
  • 4
  • 29
  • 46
1

dont mind your regional setting

you have two options in your server you convert to string and change format

yourDate.ToString("MMM dd, yyyy")

see here or here for standard and custom format

or in your extjs code you use

renderer: Ext.util.Format.dateRenderer('d-M-Y'),

see here for available format strings.

Armance
  • 5,350
  • 14
  • 57
  • 80
  • I knew it. but what if the A person like d-m-y format and another person like d/M/Y set in the computer regional setting.. Quite an issue though. I push the customer must use d-m-Y.Sometimes they always mistake because they used up to old system. – Hafizan Aziz Jan 07 '12 at 06:29
  • i had the same issue since we have customers who use 31/12/2012 and those who use 12/31/2012..thats why i write the month in letter that would be: 31 Dec 2012, that is the only solution i have found for now.Another option is to add a setting in ap for the user to choose his prefered format save it somewhere in a var timesetting and call it like this: Ext.util.Format.dateRenderer(timesetting), – Armance Jan 09 '12 at 09:47