時間中間鍵的整理
更新時間:2017年10月17日 08:44:58 投稿:lqh
這篇文章主要介紹了時間中間鍵的整理的相關(guān)資料,如有疑問請留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,需要的朋友可以參考下
時間中間鍵的整理
一下內(nèi)容是對數(shù)據(jù)接口返回的時間節(jié)點處理方法很管用的哦
import { Pipe, PipeTransform } from '@angular/core'; @Pipe({ name: 'interval' }) export class IntervalPipe implements PipeTransform { transform(value: any): any { let date = new Date(value) if (!date) { return '' } let now = new Date() let year = now.getFullYear() - date.getFullYear() if (year) { return year + '年前' } let month = now.getMonth() - date.getMonth() if (month) { return month + '月前' } let day = now.getDate() - date.getDate() if (day) { return day + '天前' } let hour = now.getHours() - date.getHours() if (hour) { return hour + '小時前' } let min = now.getMinutes() - date.getMinutes() if (min) { return min + '分鐘前' } return '剛剛'; } }
如有疑問請留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
相關(guān)文章
Jpa?Specification如何實現(xiàn)and和or同時使用查詢
這篇文章主要介紹了Jpa?Specification如何實現(xiàn)and和or同時使用查詢,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2021-11-11Mybatis-plus自定義SQL注入器查詢@TableLogic邏輯刪除后的數(shù)據(jù)詳解
這篇文章主要給大家介紹了關(guān)于Mybatis-plus自定義SQL注入器查詢@TableLogic邏輯刪除后的數(shù)據(jù)的相關(guān)資料,文中通過實例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下2023-03-03Java并發(fā)編程之詳解ConcurrentHashMap類
在之前的文章中已經(jīng)為大家介紹了java并發(fā)編程的工具:BlockingQueue接口、ArrayBlockingQueue、DelayQueue、LinkedBlockingQueue、PriorityBlockingQueue、SynchronousQueue、BlockingDeque接口,本文為系列文章第八篇.需要的朋友可以參考下2021-06-06Springboot項目通過redis實現(xiàn)接口的冪等性
這篇文章主要為大家介紹了Springboot項目通過redis實現(xiàn)接口的冪等性,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪2023-12-12