如何在午夜使用Jquery使Cookie过期?

Thi*_*ago 8 jquery jquery-plugins

我这样做了:

$.cookie("ultOS", (i), {expires:1});
Run Code Online (Sandbox Code Playgroud)

但它只会在第二天到期.

我怎样才能在午夜过期?

这会改变吗?

var date = new Date();
var midnight = new Date(date.getFullYear(), date.getMonth(), date.getDate(), 23, 59, 59);
$.cookie("ultOS", (i), {expires: midnight});
Run Code Online (Sandbox Code Playgroud)

Ada*_*rax 10

我认为这会奏效:

var currentDate = new Date();
expirationDate = new Date(currentDate.getFullYear(), currentDate.getMonth(), currentDate.getDate()+1, 0, 0, 0);
$.cookie("ultOS", "5", {expires: expirationDate});
Run Code Online (Sandbox Code Playgroud)