kettle使用js获取当前时间
时间: 2023-10-31 12:18:02 浏览: 457
要使用JavaScript获取当前时间,你可以使用以下代码:
```
var myDate = new Date();
var cyear = myDate.getFullYear();
var cmonth = myDate.getMonth() + 1;
var cday = myDate.getDate();
var chours = myDate.getHours();
var cminutes = myDate.getMinutes();
var cseconds = myDate.getSeconds();
if (cmonth < 10) {
cmonth = '0' + cmonth;
}
if (cday < 10) {
cday = '0' + cday;
}
if (chours < 10) {
chours = '0' + chours;
}
if (cminutes < 10) {
cminutes = '0' + cminutes;
}
if (cseconds < 10) {
cseconds = '0' + cseconds;
}
var created_at = cyear + '-' + cmonth + '-' + cday + ' ' + chours + ':' + cminutes + ':' + cseconds;
```
这段代码将返回一个变量`created_at`,其中包含了当前的日期和时间。你可以根据自己的需求对日期和时间的格式进行调整。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [kettle中js 获取当前时间带时区格式](https://blog.csdn.net/vcflyfeel/article/details/109485587)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [kettle获取系统时间](https://blog.csdn.net/weixin_39925813/article/details/111732167)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文