[英]How to return the time() value in Select SQL report query
I am wanting to retrieve the UNIX time()
value of an order placed from within my store cart. 我想从我的商店购物车中获取订单的UNIX
time()
值。
How do I get the Unix time from the time of order? 我如何从订购时间获得Unix时间?
I have used the following queries however they are both returning incorrect information. 我使用了以下查询,但是它们都返回不正确的信息。
1) returns the word time()
in the report, not the actual digital value. 1)返回报告中的单词
time()
,而不是实际的数字值。
DATE_FORMAT(T5.date_purchased, 'time()') As ref,
returns: time()
2) When I use the next option I get the current time, NOT the time of purchase. 2)当我使用下一个选项时,我得到的是当前时间,而不是购买时间。
DATE_FORMAT(T5.date_purchased, UNIX_TIMESTAMP()) As ref,
returns: 1421451235 17/01/2015 11:03
Note: 注意:
I have checked against the following: 我已检查以下内容:
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html
Update 更新
My query is based on this: 我的查询基于此:
Select
DATE_FORMAT(T5.date_purchased, '%Y-%m-%d') As ODate, (works)
(new line for Unix timestamp) eg: DATE_FORMAT(T5.date_purchased, UNIX_TIMESTAMP()) As ref,
From /*PREFIX*/products T1
Inner Join /*PREFIX*/orders T5 On (T5.orders_id = T2.orders_id)
The 'ref'
value was sent to the payment processing page from my cart, so it should be retrieved by SQL somehow. 'ref'
值已从我的购物车发送到付款处理页面,因此应该以某种方式由SQL检索。 zen_draw_hidden_field('ref', time()) .
Making an answer from my comment as asked: 根据要求从我的评论中回答:
Solution is to use UNIX_TIMESTAMP()
, which will return timestamp from the date/time value. 解决方案是使用
UNIX_TIMESTAMP()
,它将从日期/时间值返回时间戳。 So UNIX_TIMESTAMP(T5.date_purchased)
should return timestamp of date purchased. 因此
UNIX_TIMESTAMP(T5.date_purchased)
应该返回购买日期的时间戳。 To subtract hours use UNIX_TIMESTAMP(T5.date_purchased - interval 7 hour)
要减去小时数,请使用
UNIX_TIMESTAMP(T5.date_purchased - interval 7 hour)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.