How can we know the number of days between two given dates
using PHP?
How can we know the number of days between two given dates
using MySQL?

Answer Posted / vipul dalwala

php
-------------------------------------------------------
$noofdays = ceil(((strtotime($endDate) - strtotime
($startDate)) / (60*60*24)))


Mysql
-------------------------------------------------------
SELECT ((UNIX_TIMESTAMP('2007-10-01') - UNIX_TIMESTAMP
('2007-09-04'))/(60*60*24)) AS dateDiff;

Is This Answer Correct ?    5 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are different types of Print Functions available in PHP?

522


What is the use of header in php?

524


What type of headers that PHP supports?

610


What is the use of callback in php?

505


When you want to show some part of a text displayed on an html page in red font color? What different possibilities are there to do this? What are the advantages/disadvantages of these methods?

501






Tell us how can we display the output directly to the browser?

576


Which variable declarations within a class is invalid in php?

501


How to get number of days between two given dates using PHP?

477


Tell me is it possible to submit a form with a dedicated button?

523


Is gender a dependent variable?

504


How does php sessions work?

512


How does api connect to database?

552


Is it possible to extend the execution time of a php script?

489


The left association operator % is used in PHP for?

572


Is wordpress a php framework?

515