How to change default date format accepted by SpreadJS

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

  • 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.
  • Replied 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
  • Replied 9 September 2019, 4:59 pm EST

    Hi,
    Thanks for your response. i will try and update.

    Regards,
    Syed Mudhasir
  • Replied 10 September 2019, 2:57 pm EST

    Please take your time and let us know if you face any issues.
Need extra support?

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

Learn More

Forum Channels