简体   繁体   English

如何查询Drupal时域数据

[英]How to query drupal timefield data

Scenario: 场景:

We have a bunch of events, each event has a date field, and a separate time field that has a start and end value. 我们有很多事件,每个事件都有一个日期字段,以及一个单独的时间字段,分别具有开始和结束值。 I'm trying to build a module pulls in the next event that hasn't ended yet. 我正在尝试在尚未结束的下一个事件中构建模块提取。 Also, if there are more than one events on that day, we need to pull all of them. 另外,如果当天有多个事件,我们需要将所有事件都撤消。

My main problem is figuring out how to construct the values that I need to query that time field with, it seems to be stored is a format that I'm not familiar with, eg the value 4:30PM is stored as 59400. I can't find any documentation that specifies how to convert that value back and forth. 我的主要问题是弄清楚如何构造查询时间字段所需要的值,似乎存储的是我不熟悉的格式,例如,将4:30 PM的值存储为59400。找不到任何指定如何来回转换该值的文档。

Any Drupal gurus / php gurus out there know what that conversion is? 任何Drupal大师/ php大师都知道转换是什么?

Thanks, Neil 谢谢,尼尔

The time (59400) is in seconds. 时间(59400)以秒为单位。 So, 59400/(60x60) = 16.5 = 4:30. 因此,59400 /(60x60)= 16.5 = 4:30。

You can use the gmdate() php function: 您可以使用gmdate()php函数:

gmdate("H:i", 59400);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM