将JS日期时间转换为MySQL日期时间

将JS日期时间转换为MySQL日期时间,第1张

将JS日期时间转换为MySQL日期时间

尽管JS确实拥有足够的基本工具来执行此 *** 作,但它相当笨拙。

function twoDigits(d) {    if(0 <= d && d < 10) return "0" + d.toString();    if(-10 < d && d < 0) return "-0" + (-1*d).toString();    return d.toString();}Date.prototype.toMysqlFormat = function() {    return this.getUTCFullYear() + "-" + twoDigits(1 + this.getUTCMonth()) + "-" + twoDigits(this.getUTCDate()) + " " + twoDigits(this.getUTCHours()) + ":" + twoDigits(this.getUTCMinutes()) + ":" + twoDigits(this.getUTCSeconds());};


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5440287.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-11
下一篇 2022-12-11

发表评论

登录后才能评论

评论列表(0条)

保存