dsfdf854456 2017-02-17 09:27
浏览 39
已采纳

JS / PHP,日期时间

i would like to ask, if someone know to to make in JS or PHP time of date.

Or how long we're together, like 70 days or 2 month and some days, and all day add 1 more day. I have something whats work, but on begging of that time is - . I spent a lot time with making something what should work. But nothing.

There is that code with that -

<script charset="UTF-8">


function daysTill() {

  var day=      8 
  var month=    12 
  var year=    2016 
  var event=    "relationship with my ♥"
  var end =     "days of"


  var daystocount=new Date(year, month -1, day)
  today=new Date()
  if (today.getMonth()==month && today.getDate()>day)
  daystocount.setFullYear(daystocount.getFullYear())
  var oneday=1000*60*60*24
  var write = (Math.ceil((daystocount.getTime()-today.getTime())/(oneday)))
  document.write('<strong>'+write +'</strong> '+end+' '+event)
}

  daysTill();

</script> 

if someone know, please help me. Thanks ♥

  • 写回答

3条回答 默认 最新

  • dsdzvprlp51692469 2017-02-17 09:41
    关注

    The getTime() method returns the time in milliseconds so to convert it to days you divide that by 86400000 (1000 for seconds * 60 for minutes * 60 for hours * 24 for days):

    var relationship = new Date("2016/12/08");
    var today = new Date();
    var days = Math.ceil((today.getTime() - relationship.getTime()) / 86400000);
    
    document.write(days + " days have pass since the start of the relationship.");

    </div>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本