時(shí)間中間鍵的整理
時(shí)間中間鍵的整理
一下內(nèi)容是對(duì)數(shù)據(jù)接口返回的時(shí)間節(jié)點(diǎn)處理方法很管用的哦
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 + '小時(shí)前' } let min = now.getMinutes() - date.getMinutes() if (min) { return min + '分鐘前' } return '剛剛'; } }
如有疑問(wèn)請(qǐng)留言或者到本站社區(qū)交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!
相關(guān)文章
Spring入門(mén)到精通之Bean標(biāo)簽詳解
這篇文章主要為大家詳細(xì)介紹了Spring中Bean的標(biāo)簽,文中的示例代碼講解詳細(xì),對(duì)我們學(xué)習(xí)Spring有一定的幫助,快跟隨小編一起學(xué)習(xí)學(xué)習(xí)吧2022-07-07Jpa?Specification如何實(shí)現(xiàn)and和or同時(shí)使用查詢(xún)
這篇文章主要介紹了Jpa?Specification如何實(shí)現(xiàn)and和or同時(shí)使用查詢(xún),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2021-11-11SpringBoot使用Jwt處理跨域認(rèn)證問(wèn)題的教程詳解
這篇文章主要介紹了SpringBoot使用Jwt處理跨域認(rèn)證問(wèn)題,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-06-06Mybatis-plus自定義SQL注入器查詢(xún)@TableLogic邏輯刪除后的數(shù)據(jù)詳解
這篇文章主要給大家介紹了關(guān)于Mybatis-plus自定義SQL注入器查詢(xún)@TableLogic邏輯刪除后的數(shù)據(jù)的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2023-03-03Java如何獲取接口所有的實(shí)現(xiàn)類(lèi)
這篇文章主要介紹了Java如何獲取接口所有的實(shí)現(xiàn)類(lèi),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-01-01Java并發(fā)編程之詳解ConcurrentHashMap類(lèi)
在之前的文章中已經(jīng)為大家介紹了java并發(fā)編程的工具:BlockingQueue接口、ArrayBlockingQueue、DelayQueue、LinkedBlockingQueue、PriorityBlockingQueue、SynchronousQueue、BlockingDeque接口,本文為系列文章第八篇.需要的朋友可以參考下2021-06-06Springboot項(xiàng)目通過(guò)redis實(shí)現(xiàn)接口的冪等性
這篇文章主要為大家介紹了Springboot項(xiàng)目通過(guò)redis實(shí)現(xiàn)接口的冪等性,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-12-12Java enum的用法詳細(xì)介紹及實(shí)例代碼
這篇文章主要介紹了Java enum的用法詳細(xì)介紹及實(shí)例代碼的相關(guān)資料,需要的朋友可以參考下2017-02-02