Kendo Angular 2 Grid DateTime format

前端 未结 4 813
一个人的身影
一个人的身影 2021-01-13 07:28

Does anyone know how to properly format a DateTime in the grid? (Is this datatype even supported?).

No matter what I put in the \"filter\" property of the column, my

4条回答
  •  独厮守ぢ
    2021-01-13 07:57

    I solved the same issue using a date pipe in a template column. Make sure you check for null values.

    
        
            
    {{ formatDate(dataItem.lastLoginDate) | date:"shortDate" }}

    function in component.ts pulls out the usable part of the date string and converts it to a JS date so the Date Pipe can use it.

    formatDate(myStringDate) {
        return new Date(parseInt(myStringDate.substr(6)));
    }
    

    I used the shortDate format, but you can find more format options here including time formats: Angular 2 Date Pipe Formatters

提交回复
热议问题