Open Closed

Application wide Datetime format and conversion #6801


User avatar
0
sukhdeep.dhillon created
  • ABP Framework version: v7.2.2
  • UI Type: Angular
  • Database System: EF Core (SQL Server)

Hi,

in ABP, is there any specific way to implement the following:

  1. How to convert application wide datetime from UTC to EST
  2. Format datetime for all API responses

4 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    You can try:

    Configure<AbpClockOptions>(options =>
    {
        options.Kind = DateTimeKind.Utc;
    });
    

    Then you can set the time zone in the settings page

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Format datetime for all API responses

    can you elaborate

  • User Avatar
    0
    sukhdeep.dhillon created

    thanks you for your response if return Dto has property of type DateTime then it should follow some kind of format like yyyy-MM-dd like that

    how can I set any kind of specific format for all DateTime type

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    You can configure the AbpJsonOptions

    https://docs.abp.io/en/abp/latest/JSON#abpjsonoptions

    services.Configure<AbpJsonOptions>(options =>
    {
        options.OutputDateTimeFormat = "yyyy-MM-dd";
    });
    
Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11