【问题标题】:Defining and comparing TIMESTAMP variable with jQuery/Javascript ?使用 jQuery/Javascript 定义和比较 TIMESTAMP 变量?
【发布时间】:2013-01-08 17:14:57
【问题描述】:

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

ps。我的表格在 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");
 }

 });

感谢您的帮助

【问题讨论】:

    标签: javascript jquery sql css


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-01
      • 2012-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多