ISO8601DateUtils.jsm 编辑
The ISO8601DateUtils.jsm
JavaScript code module provides methods that make it easy to convert JavaScript Date
objects into ISO 8601 format date strings and back.
To use this, you first need to import the code module into your JavaScript scope:
Components.utils.import("resource://gre/modules/ISO8601DateUtils.jsm");
Once you've imported the module, you can then use the ISO8601DateUtils
object it exports.
Using the ISO 8601 date utilities
To convert a date string into a Date
object, simply use:
dateObj = ISO8601DateUtils.parse(dateString);
To convert a Date
object into a date string:
dateString = ISO8601DateUtils.create(dateObj);
Method overview
String create(aDate); |
Date parse(aDateString); |
Methods
create
Creates an ISO 8601 format date string, e.g. "2010-05-15T13:45:00Z", from a JavaScript Date
object.
String create( aDate );
Parameters
aDate
- A JavaScript
Date
object to translate into an ISO 8601 format string.
Return value
An ISO 8601 format date string.
parse
Converts an ISO 8601 format date string into a JavaScript Date
object.
Date parse( aDateString );
Parameters
- aDateString
- An ISO 8601 format date string.
Return value
A JavaScript Date
object corresponding to the specified date string.
See also
- Using JavaScript code modules
- JavaScript code modules
Date.parse
for reading ISO8601 datesDate.toISOString
for putting out ISO8601 dates
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论