Jump to content

Search the Community

Showing results for tags 'date difference calculation'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. I am trying to track the time of resolution of complaints in my application, so i have tried to get the difference between the time a problem was reported and date it was resolved as shown in code below. I have noticed that calculating the difference between the time expressions uses only the date parts of the values. so 5-01-2014 minus 27-12-2013 returns -2 days instead of 9 days. I have also noticed that the MySQL DATEDIFF() Function uses only the date parts of the values in the calculation too. How may I get the correct duration returned as days? Thanks. <?php require_once('./includes/connection.inc.php'); $conn = dbConnect('read'); $sql = 'SELECT date_format(reported, "%d-%m-%Y") AS date_reported, date_format(Date_Resolved, "%d-%m-%Y") AS date_resolved FROM complaints ORDER BY created DESC'; $result = $conn->query($sql) or die(mysqli_error()); $numRows = $result->num_rows; ?> <!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>Customer Complaints</title> </head> <body> <table> <thead> <tr> <th>Resolution Period</th> </tr> </thead> <tbody> <?php while ($row = $result->fetch_assoc()) { $date1=$row["date_reported"]; $date2=$row["date_resolved"]; ?> <tr> <td> <?php echo $date2-$date1; ?> days</td> </tr> <?php } ?> </tbody> </table> </body> </html>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.