如何找到字符串时间戳 [英] how to find a timestamp in string
问题描述
我正在运行的SQL和检索该数组:
I am running a sql and retrieving this array:
array(
732 => string '1291385393<>victorias<><><>Application reminder email sent (documentation needed).|1291396439<>smalamatinas<><><>Busy, so will call us on Monday. ' (length=146)
765 => string '1290005590<>smalamatinas<><><>Waiting for phone number. ' (length=56)
767 => string '1300373010<>susanm<><><>Email sent 17/3/11 re availability to work|1364469282<>sarahn<><><>emailed. ' (length=100)
)
很不幸,这是很老的code不要打我这个垃圾种类编码字符串数据。我想这种情况发生时的笔记被保存在数据库中,我可以' t触他们,因为系统可能会断裂。
Unfortunately this is very old code don't hit me for this rubbish kind of coding and string data. I am thinking this happens when notes are being saved in database and I can't touch them because the system might break.
我怎么找到当前日期或我的笔记时间戳(2015年)和上面的日期?
我不知道是否preg_match()会BA好主意吗?
how do I find dates from current date or(2015) and above in my notes timestamp? I don't know whether preg_match() would ba good idea?
或者,如果我能我的条件分配到MySQL查询?
Or if I could assign my condition into mysql query?
推荐答案
presumably这十位整数是* nix的时间戳,虽然你没有明说明确。您可以使用MySQL,只要你愿意忽略之后来到时间戳来获取这些项目的一个子集|在您的数据。
Presumably these ten-digit integers are *nix timestamps, although you didn't say so explicitly. You can use MySQL to retrieve a subset of these items as long as you're willing to ignore the timestamps that come after "|" in your data.
例如,下面的查询将这样做。
For example, this query will do that.
SELECT FROM_UNIXTIME(message) AS timestamp,
message
FROM note
WHERE FROM_UNIXTIME(message) >= '2011-01-01'
下面是一个例子。 http://sqlfiddle.com/#!2/ce9761/4/0
这篇关于如何找到字符串时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!