[英]How do I convert a Date String to a Timestamp with different date formats?
I am using bootstrap datetimepicker.js plugin in an application. 我在应用程序中使用bootstrap datetimepicker.js插件。 The plugin allow me to format the date to this:
dd-MM-yyyy hh:mm:ss
(10-09-2014 00:30:30) and I am trying to convert it to a timestamp so that I can use it in a sql statement. 该插件允许我将日期格式化为:
dd-MM-yyyy hh:mm:ss
(10-09-2014 00:30:30)我试图将其转换为时间戳,以便我可以在一个sql语句。 I am trying to use TO_TIMSTAMP()
oracle function but when I try run the following line: 我试图使用
TO_TIMSTAMP()
oracle函数但是当我尝试运行以下行时:
TO_TIMESTAMP('10-09-2014 00:30:00', 'DD-MON-YYYY hh:mi:ss')
I get an execution error saying invalid month. 我收到执行错误,说无效月份。 Is there a step I a missing?
我有一个缺失的步骤吗? I have tried to adjust the format of the bootstrap plugin but it does not return the documented result.
我试图调整bootstrap插件的格式,但它不会返回记录的结果。 Ant suggestions?
蚂蚁建议?
正确的月份格式将是MM而不是MON:
TO_TIMESTAMP('10-09-2014 00:30:00', 'DD-MM-YYYY hh:mi:ss')
You can do this using JavaScript Date object . 您可以使用JavaScript Date对象执行此操作。
var date = new Date('10-09-2014 00:30:00');
date.getTime();
or just: 要不就:
var timestamp = new Date('10-09-2014 00:30:00').getTime();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.