[英]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.