【问题标题】:How to show one hour before and after one hour from the reminder time如何显示提醒时间前一小时和一小时后的一小时
【发布时间】:2020-12-17 17:37:47
【问题描述】:

我需要在提醒时间一小时之前和一小时之后显示提醒,现在它显示完整的提醒日期

 $(document).ready(function() {
 var dsr = <?=$todo['dsr']?>;
 let dsr_str ='<ul>';
 $.each(dsr, function(index, item){
 let now = new moment(item['reminder_date']);
  dsr_str += '<li>'+item['company']+' | '+item['phone']+' | <b>'+now.format("hh:mm A")+'</b></li>';
    });
    dsr_str +='</ul>'
$(document).Toasts('create', {
      title: 'DSR Reminder',
      // position: 'bottomLeft',
      class: 'bg-danger', 
      body: dsr_str
    })
  }
  
});

【问题讨论】:

    标签: javascript jquery momentjs


    【解决方案1】:

    尝试使用它来格式化日期对象:

    const d = new Date()
    const h = d.getHours();
    const r = h.toString().padStart(2,"0")+":"+d.getMinutes().toString().padStart(2,"0") + h>12?"pm":"am"
    

    【讨论】:

    • 其实我不会怎么输入代码你能帮我撤消吗_
    猜你喜欢
    • 2014-11-26
    • 2017-07-02
    • 2011-04-05
    • 1970-01-01
    • 1970-01-01
    • 2020-11-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多