十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
这篇文章主要介绍python中时间中间键的示例分析,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

站在用户的角度思考问题,与客户深入沟通,找到凯里网站设计与凯里网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:成都做网站、成都网站制作、企业官网、英文网站、手机端网站、网站推广、域名注册、虚拟主机、企业邮箱。业务覆盖凯里地区。
时间中间键的整理
一下内容是对数据接口返回的时间节点处理方法很管用的哦
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 '刚刚';
}
}以上是“python中时间中间键的示例分析”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注创新互联行业资讯频道!