gpt4 book ai didi

javascript - 使用 jQuery/Javascript 定义和比较 TIMESTAMP 变量?

转载 作者:行者123 更新时间:2023-11-28 13:25:33 24 4
gpt4 key购买 nike

我有一个表,其中有一列使用来自 Oracle 数据库的时间戳变量。我不确定如何使用 JQuery 从 SQL 查询定义我的 var“计划时间”并运行条件。我基本上是将列时间戳与系统时间进行比较并返回行背景颜色。

附言。我的表在 aspx 页面中

// declaring the time

var currentTime = new Date();
var scheduledTime = "not sure how to declare the variable from my dynamic table"

// variables for the table
var rows = document.getElementById('ewGrid').getElementbyTagName('tr');

// style class
.rowRed {background-color:red; color:white;}
.rowYellow {background-color:red; color white}


$('tr').each(function() {
// if value is a number and less then zero
if (currentTime - scheduledTime) >15mins<=30mins ) {
tr = $(this).parent();
tr.addClass("rowRed");
}

});

感谢任何帮助

最佳答案

unix 时间戳的精度为秒,因此转换为毫秒并传递给 Date 构造函数:

var scheduledTime = new Date(unixtimestamp*1000)
// where unixtimestamp is the timestamp you get from the database

关于javascript - 使用 jQuery/Javascript 定义和比较 TIMESTAMP 变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14220491/

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