javascript - 我正在处理 django 上的日期,有没有办法比较 html 上的呈现日期以检查当前日期是否还剩不到 3 天
问题描述
我有这个代码,它通常显示数据库上的所有行数。有没有办法将返回的日期(承诺日期)与 javascript 或 jquery 进行比较,以便我可以突出显示距今天日期不到 3 天的所有日期。谢谢
<div class="container">
<table id="requirement_table" class="table table-bordered table-hover table-sm" style="width:100%">
<thead>
<tr>
<th>Applicant Name</th>
<th>Requirement</th>
<th>Remarks</th>
<th>Promised Date</th>
<th>Completed</th>
</tr>
</thead>
<tbody>
{% for req in app_requirements %}
<tr>
<th>{{ req.applicant }}</th>
<th>{{ req.requirement }}</th>
<th>{{ req.remarks }}</th>
<th>{{ req.date_promised }}</th>
<th>{{ req.completed }}</th>
</tr>
{% endfor %}
</tbody>
</table>
</div>
解决方案
将字符串转换为日期对象并将其与您需要的日期进行比较。
let myDate = getDateSomewhere();
Date.parse(myDate);
推荐阅读
- powershell - 将值传递给 TeamCity 元运行程序中的 PowerShell 脚本
- amazon-redshift - Redshift 临时表身份列
- pandas - 比较和删除熊猫中的行
- python - 使用 crontab 时处理子文件夹
- flutter - 在构建 Home(dirty, state: _HomeState#75cb9) 时引发了以下 ArgumentError:
- bash - for循环中的Bash shell任务
- wordpress - 来自自托管服务器的 Wordpress 插件自动更新
- reinforcement-learning - 在 A2C 中创建分离的演员和评论家模型,ray[rrlib]
- debugging - 如何避免自定义 Julia 迭代器中的内存分配?
- c# - 覆盖 GetHashCode() - 散列的随机分布有多重要?