0

Typo3 中是否有办法以优雅的方式查询日期?我对 *tt_content* 字段日期进行了实验,发现日期保存为 10 个字符长的整数。我认为它是另一种格式。

我想要这样的东西:

10 < styles.content.getLeft
10 {
  select {
    where = date = %y2011 //everything with year 2011
  }
}

或者

10 < styles.content.getLeft
10 {
  select {
    where = date > 23-1-1996
  }
}
4

2 回答 2

1

日期在typo3表中保存为unix时间戳,这是保存日期的标准方式,您必须将unix时间戳转换为日期或日期转换为unix时间戳,在php中有date/strftime函数,在typoscript中我很快找到了这个在此处输入链接描述

temp.current_date = TEXT
temp.current_date {
  data = yourdate (for example 2011) : U
  strftime = %A, %e. %B %Y
}

在这里您将日期转换为 unix 时间戳,之后您可以在查询中使用 temp.current_date

select {
    where = date > yourdate
}
于 2012-01-06T15:40:01.473 回答
1

如前所述,日期保存为 UNIX 时间戳,因此需要在 SQL 查询中使用时间戳。您可以使用UNIX_TIMESTAMP()MySQL 的功能,以便您可以轻松地创建查询:

10 < styles.content.getLeft
10 {
  select {
    where = date > UNIX_TIMESTAMP('1996-01-23 23:59:59')
  }
}
于 2012-01-10T11:18:11.373 回答