Jump to content

Search the Community

Showing results for tags 'calculator'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • 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 (Dreamweaver, Zend, 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


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Donation Link

Found 1 result

  1. Hello All, I'm a student currently enrolled in a PHP course, and our instructor has told us to create code that would accept a users birthday and then calculate how many days from today is their next birthday. The program returns a value, but the value is incorrect. I should never receive a value over 365 days. Example: Input: 04/11/1985 Today's Date is 11/9/2016 Output (should be): "You have 153 days until your next Birthday" Actual Output: "You have 212 days until your next Birthday" What did I do wrong? Thanks in advance for any assistance Michelle <?php $johnsBirthday = $_GET ['JohnBday']; $jakesBirthday = $_GET ['JakeBday']; $john_bday = new DateTime($_GET['JohnBday']); $jake_bday = new DateTime($_GET['JakeBday']); $today_date = new DateTime(); switch (true) { case ($john_bday < $today_date) : $today_date->setDate($john_bday->format('Y'), $today_date->format('m'), $today_date->format('d')); break; case ($today_date < $john_bday) : $john_bday->setDate($today_date->format('Y'), $john_bday->format('m'), $john_bday->format('d')); break; } switch (true) { case ($today_date < $jake_bday) : $jake_bday->setDate($today_date->format('Y'), $jake_bday->format('m'), $jake_bday->format('d')); break; case ($jake_bday < $today_date) : $jake_bday->setDate($today_date->format('Y'), $jake_bday->format('m'), $jake_bday->format('d')); break; } $john_interval = $john_bday->diff($today_date); $john_diff = $john_interval->format('%a'); echo "John you have $john_diff days until your next Birthday</br>"; $jake_interval = $jake_bday->diff($today_date); $jake_diff = $jake_interval->format('%a'); echo "Jake you have $jake_diff days until your next Birthday</br>"; if ($johnsBirthday < $jakesBirthday) { echo "John is older than Jake</br>"; } elseif ($johnsBirthday > $jakesBirthday) { echo "Jake is older than John</br>"; } else { echo "Jake and John are twins"; } ?>
  • 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.