[英]How Can I calculate age from stored date birth in mysql Table using php
[英]How Can I Calculate remain days of the year from stored Date in mysql using php
我有两个表订单和股票。 订单表具有名为“Order_Date”的列,而共享表具有名为“HoldingPeriod”的列,因此我如何确定 365 天后的客户订单(Order_Date)的剩余天数。 请帮助我不知道如何启动代码,但这里是来自共享表的查询;
<?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'];
}?>
这是查询付费订单的代码
<?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'];
}
?>
使用以下代码片段
$currentDate = date("Y-m-d");
$totalDays = $Maturity;
$usedDays = round(abs(strtotime($currentDate)-strtotime($orderdate))/86400);
$remainingDays = $totalDays-$usedDays;
希望这可以帮助您解决问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.