Announcement

Collapse
No announcement yet.

change format of datetime in espocrm

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    It can be done only in code. client/src/views/fields/data.js # getValueForDisplay

    Comment


    • #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


      • #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


        • #5
          Originally posted by shalmaxb View Post
          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...
          X