gpt4 book ai didi

javascript - jquery,处理日期

转载 作者:行者123 更新时间:2023-11-30 08:16:00 24 4
gpt4 key购买 nike

如何在 jQuery 中处理日期?我想执行迄今为止的数学运算。

var date = '2010-11-23 21:32:31';
var date = date - 70;
alert(date);

如何获得:2010-11-23 21:31:21

谢谢

最佳答案

尝试:

http://www.datejs.com/

它不是 jQuery,但可以解决您的问题。

来自他们的示例页面:

// What date is next thrusday?
Date.today().next().thursday();

// Add 3 days to Today
Date.today().add(3).days();

// Is today Friday?
Date.today().is().friday();

// Number fun
(3).days().ago();

// 6 months from now
var n = 6;
n.months().fromNow();

// Set to 8:30 AM on the 15th day of the month
Date.today().set({ day: 15, hour: 8, minute: 30 });

// Convert text into Date
Date.parse('today');
Date.parse('t + 5 d'); // today + 5 days
Date.parse('next thursday');
Date.parse('February 20th 1973');
Date.parse('Thu, 1 July 2004 22:30:00');

关于javascript - jquery,处理日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4017910/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com