处理时间跨度的最佳方式? [英] Best way to work with timespans?

查看:38
本文介绍了处理时间跨度的最佳方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有首选的类或方法来处理 PHP 中的时间跨度?我感兴趣的主要功能是检查日期是否在时间跨度内,或者为上下限生成时间戳.

Is there a preferred class or method for working with timespans in PHP? The primary functionality I am interested in is checking if a date is within the timespan, or generating timestamps for the lower and upper limits.

推荐答案

使用 unix 时间戳.如果是mysql数据,那么你可以像这样存储时间戳,如果不是那么你也可以将mysql datetimes转换为unix时间戳.

use the unix timestamp. If it's mysql data, then you can store timestamps like this, if not then you can also convert mysql datetimes to unix timestamps.

php.net 站点上有大量关于此功能的文档,但它们都相对简单且易于使用.

There is a bunch of documentation on the functionality pertaining to this at the php.net site, but it's all relatively simple and easy to use.

祝你好运.

这篇关于处理时间跨度的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆