How to change default date format accepted by SpreadJS

Posted by: syedmudhasir.m on 5 September 2019, 5:42 pm EST

    • Post Options:
    • Link

    Posted 5 September 2019, 5:42 pm EST

    In SpreadJS may i know how to change the default Date format e.i. I am setting a date format as

    activeSheet.getCell(args.row, args.col).formatter(new GC.Spread.Formatter.GeneralFormatter(“dd/MM/yyyy hh:mm:ss tt”, “en-us”));

    Its working fine when i am giving date in MM/dd/yyyy format but when i am giving date in dd/MM/yyyy format above code is not updating the format.

  • Posted 8 September 2019, 6:18 pm EST

    Hi,

    We could set the default date format by setting the shortDatePattern for DateTimeFormat. Please refer to the following code snippet and the sample which demonstrates the same:

    var myCulture = new GC.Spread.Common.CultureInfo();
    // set default date format to use
    myCulture.DateTimeFormat.shortDatePattern = "dd/MM/yyyy";
    GC.Spread.Common.CultureManager.addCultureInfo("my-culture", myCulture);
    // update culture
    GC.Spread.Common.CultureManager.culture("my-culture");
    

    https://codesandbox.io/s/spread-js-starter-jfqix

    API references:

    • CultureInfo class: http://help.grapecity.com/spread/SpreadSheets12/webframe.html#SpreadJS~GC.Spread.Common.CultureInfo.html

    • Culture manager: http://help.grapecity.com/spread/SpreadSheets12/webframe.html#SpreadJS~GC.Spread.Common.CultureManager.html

    Regards

    Sharad

  • Posted 9 September 2019, 4:59 pm EST

    Hi,

    Thanks for your response. i will try and update.

    Regards,

    Syed Mudhasir

  • Posted 10 September 2019, 2:57 pm EST

    Please take your time and let us know if you face any issues.

  • Posted 5 April 2023, 2:25 am EST

    Hi,

    After adding the following code I still see MM/dd/yyyy format. But if I double click to edit the cell it becomes dd/MM/yyyy.

    var myCulture = new GC.Spread.Common.CultureInfo();
    // set default date format to use
    myCulture.DateTimeFormat.shortDatePattern = "dd/MM/yyyy";
    GC.Spread.Common.CultureManager.addCultureInfo("my-culture", myCulture);
    // update culture
    GC.Spread.Common.CultureManager.culture("my-culture");
  • Posted 5 April 2023, 5:52 pm EST

    Dear Moudud,

    It appears that you have opened a distinct case regarding the issue mentioned at https://www.grapecity.com/forums/spreadjs/spreadjs.

    I have already responded to the forum case mentioned, providing a solution. You may refer to the aforementioned case for further details. If you require further help with this matter, please update the mentioned case, and I will gladly assist you.

    Best regards,

    Ankit

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels