change format of datetime in espocrm

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hoangphuc091
    Junior Member
    • Feb 2015
    • 7

    change format of datetime in espocrm

    I want to change the format display of datetime in espocrm. Default format is very difficult. I want to change to dd/mm/yyyy. Ex: Jan 23, 1990 -> 23/01/1990
  • yuri
    Member
    • Mar 2014
    • 8455

    #2
    It can be done only in code. client/src/views/fields/data.js # getValueForDisplay
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • Decepticon
      Junior Member
      • Jul 2023
      • 18

      #3
      I modified client/src/views/fields/data.js based on an old guide, but it seems it no longer has any effect.

      Before
      Code:
      // Need to use UTC, otherwise there's a DST issue with old dates.
      dateTime = moment.utc(valueWithTime, internalDateTimeFormat);
      
      if (dateTime.format('YYYY') === today.format('YYYY')) {
      return dateTime.format(readableFormat);
      }
      
      return dateTime.format(readableFormat + ', YYYY');
      }
      After
      Code:
      // Need to use UTC, otherwise there's a DST issue with old dates.
      dateTime = moment.utc(valueWithTime, internalDateTimeFormat);
      
      if (dateTime.format('YYYY') === today.format('YYYY')) {
      return dateTime.format('DD/MM/YYYY');
      }
      
      return dateTime.format('DD/MM/YYYY');
      }

      Comment

      • shalmaxb
        Senior Member
        • Mar 2015
        • 1606

        #4
        Hello,
        to avoid display as "yesterday" or alike, check the checkbox in your datefield to "numeric value". For single date fields you could use the formula datetime/format -> https://docs.espocrm.com/administrat...datetimeformat

        With this approach you won`t have to code anything.

        Comment

        • Decepticon
          Junior Member
          • Jul 2023
          • 18

          #5
          Originally posted by shalmaxb
          Hello,
          to avoid display as "yesterday" or alike, check the checkbox in your datefield to "numeric value". For single date fields you could use the formula datetime/format -> https://docs.espocrm.com/administrat...datetimeformat

          With this approach you won`t have to code anything.
          That's great! It's working perfectly. Thank you for sharing this

          Comment

          Working...