dtkvlj5386 2014-02-09 03:05
浏览 15

修改java / php

I want to modify this, because it only worked in .asp files, and now my document is in .php

But this script,, it's annoying me. What i want to do is, calculating how many days has gone since year 1858 month 3 and day 21 Until now, and ofc it needs to say "Today the union has existed for "year" & "month" & days"

Hope u can help!

<div id="idag" align="center"><p>I dag har foreningen eksisteret i 
<%=DateDiff("yyyy",#1858-03-21#,#2014-01-01#)%>
 år og 
<% 'Noter at der er fratrukket 20 dage fra dage. Detta må korrigeres vid skudår!' %> 
<%=DateDiff("d",#2014-01-22#,now)%> dage</p></div> 
  • 写回答

2条回答 默认 最新

  • dsk61780 2014-02-09 03:12
    关注

    So you need to get the difference between two dates - now and the given date and then format it into a sentence using php. The below should suffice. You'll get warnings if you don't have a timezone set, though, but I assume you have that covered.

    Here's the PHPFiddle for a test run.

    <?php
    
        $datetime1 = date_create('now');
        $datetime2 = date_create('1858-03-21');
        $interval = date_diff($datetime1, $datetime2);
        echo $interval->format('Today the union has existed for %y years, %m months, and %d days.');
    
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决