在MySQL中将dd/mm/yyyy字符串转换为Unix时间戳 [英] Convert dd/mm/yyyy string to Unix timestamp in MySQL
本文介绍了在MySQL中将dd/mm/yyyy字符串转换为Unix时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的表中,我有一个名为date
的varchar列,其中包含以dd/mm/yyyy格式表示的日期的字符串表示形式.如何在SELECT查询中将这些转换为Unix时间?
In my table I have a varchar column called date
containing string representations of dates in dd/mm/yyyy format. How can I convert these to Unix times in a SELECT query?
推荐答案
select unix_timestamp(str_to_date('30/05/2011','%d/%m/%Y'));
或:
select unix_timestamp(str_to_date(myfield,'%d/%m/%Y')) from mytable;
这篇关于在MySQL中将dd/mm/yyyy字符串转换为Unix时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文