简体   繁体   English

如何使用php从mysql中存储的日期计算一年中的剩余天数

[英]How Can I Calculate remain days of the year from stored Date in mysql using php

I have two tables orders and shares.我有两个表订单和股票。 order table has column called 'Order_Date', while share table has column called 'HoldingPeriod' so how can I determine the remaining days of customer order (Order_Date) from 365 days.订单表具有名为“Order_Date”的列,而共享表具有名为“HoldingPeriod”的列,因此我如何确定 365 天后的客户订单(Order_Date)的剩余天数。 Please, Help I don't have any idea on how to initiate code on this but here is query from share table;请帮助我不知道如何启动代码,但这里是来自共享表的查询;

 <?php
$SeeShare=ViewShares();
while($row=mysql_fetch_array($SeeShare))
{
    $share = $row['ShareName'];
    $numshares = $row['NumberShares'];
    $askprice = $row['AskPrice'];
    $bidprice = $row['BidPrice'];
    $commfee = $row['CommFee'];
    $ShareInterest=$row['CommPercent'];
    $Maturity=$row['HoldingPeriod'];
}?>

Here is the code for querying Paid Orders这是查询付费订单的代码

<?php

 $status='';
$Paid=QueryPaidFor($status);
  while($row=mysql_fetch_array($Paid))
  {

      $share=$row['ShareName'];
      $sharenum=$row['NumberShares'];
      $amount=$row['Order_Price'];
      $status=$row['status'];
      $orderdate=$row['OrderDate'];

     }

    ?>

Use the following code snippet使用以下代码片段

$currentDate = date("Y-m-d");
$totalDays = $Maturity;
$usedDays = round(abs(strtotime($currentDate)-strtotime($orderdate))/86400);
$remainingDays = $totalDays-$usedDays;

Hope this helps you in solving the problem.希望这可以帮助您解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用php从mysql表中存储的出生日期计算年龄 - How Can I calculate age from stored date birth in mysql Table using php 如何使用 oop php mysql 中的当前日期检查距离预定义日期还有多少年、月和天 - How can I Check How Many Years, Months and Days Left From Predefined Date using Current Date in oop php mysql 如何使用 PHP 计算某个特定年份的“5 月的第二个星期一”等规则指定的日期? - How can I calculate the date specified by a rule like “The second Monday in May” for a gievn year using PHP? 如何在php中使用mysql表字段值计算剩余天数 - How Can I Calculate Remaining Days using mysql table field value in php 如何在MySQL存储过程中计算这些日期差和乘法? - How can I calculate these date difference,multiplication in a MySQL stored procedure? 我如何使用php从mysql计算出勤率 - how can i calculate the percentage of attendance from mysql using php 尝试使用计算(当前php日期-mySQL时间戳=天数差) - Trying to calculate using (current php date - mySQL timestamp = difference in days) 使用MySQL和PHP计算日期期间的占用天数 - Calculate Number of Occupied Days within a date period using MySQL and PHP mysql&php-如何从多个日期范围中计算总的经验年数? - mysql & php - How to calculate total year of experience from multiple date range? MYSQL/PHP 如何从日期减去 7 天? - MYSQL/PHP how to minus 7 days from date?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM