使用Javascript将字符串(日期格式)转换为日期时间 [英] Convert a string (in date format) to datetime using Javascript
问题描述
在BIRT中,我有一列包含以字符串形式存储的日期时间.我需要将这些字符串转换为日期时间格式,然后使用Javascript将结果放入另一列中. 字符串的格式为:例如:2014年2月21日,星期五,上午09:40.
In BIRT, i have a column containing a datetime stored as a string. I need to convert these string to datetime format and put the result in another column using Javascript. The string is the form of: for example: Fri 21 Feb 2014, 09:40 AM.
因此,将其转换为日期时间格式并导出为excel时,应将该列视为日期. 你们中的任何一个可以帮助我做到这一点吗?
Hence this when converted to a datetime format and exported to excel, the column should be treat as a date. Can any one of you help me to do it?
干杯
推荐答案
在BIRT上下文中,其他答案未考虑此问题.
Other answers do not take into consideration this question is in a BIRT context.
- 在数据集中创建一个以日期时间"为数据类型的计算列
- 输入表达式:
新日期(行["myDateStringField"]);
new Date(row["myDateStringField"]);
其中"myDateStringField"是您的String格式的DateTime列.然后在报表中使用此计算列而不是字符串"列.
Where "myDateStringField" is your DateTime column in a String format. Then use this computed column in your report instead of the String column.
就是这样!
这篇关于使用Javascript将字符串(日期格式)转换为日期时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!