Jump to content

Recommended Posts

i have a database name movie and the fields are "datestart ", "dateended ". my problem is i want to retrieve the date that the movie is STARTED until the date that the movie is ENDED. example; date started is august 8, 2013, and the date ended is august 14, 2013 may concern is how to retrieve the date august 9, 2013, august 10, 2013 until august 13, 2013 

 

 

 
// this is my code
<?php $q = mysql_query("select * from movie "); 
  
$row = mysql_fetch_array($q); 
$sdate=$row['datestart'];
$edate=$row['dateended'];
 
while($sdate<=$edate){ 
   
echo "<option value=$sdate>$sdate</datestart>"; 
 
$sdate=mktime(0,0,0,date("m"),(date("d")+1),date("Y"));
 
}
?>
 
Edited by phpbigenner
Link to comment
https://forums.phpfreaks.com/topic/280927-how-to-add-date/
Share on other sites

Assuming datestart and dateended are integers (not date/time strings) then you're close, you just have to fix the

$sdate=mktime(0,0,0,date("m"),(date("d")+1),date("Y"));
so that it doesn't go according to today's date but instead adds one day to $sdate. Like

$sdate = strtotime("+1 day", $sdate);
But there might be another problem. datestart and dateended: they really are integers, right? They have precision to the second so how are you dealing with the fact that you only care about the date portion? Do they correspond to midnight on their respective days?
Link to comment
https://forums.phpfreaks.com/topic/280927-how-to-add-date/#findComment-1443877
Share on other sites

thanks bro. I fix my problem.

 

 

 

 
// this is my code now
// datestart and dateended are strings
 
 <?php $q = mysql_query("select * from movie "); 
  
$row = mysql_fetch_array($q); 
$sdate=$row['datestart'];
$edate=$row['dateended'];
 
while($sdate<=$edate) { 
   
echo "<option value=$sdate>$sdate</$sdate>"; 
 
$sdate =date('m/d/Y', strtotime('+1 day', strtotime($sdate)));
}
?>
 
Link to comment
https://forums.phpfreaks.com/topic/280927-how-to-add-date/#findComment-1443942
Share on other sites

hey guy's! I have a problem again on how to trap the time. example if the datestart is 08/12/2013 and the date dateended is 08/12/2013. what should i do to display the dateended until it will greater than 12 AM in the midnight.

 

 

// this is my code now
// datestart and dateended are strings
 
 <?php $q = mysql_query("select * from movie "); 
 
$row = mysql_fetch_array($q); 
$sdate=$row['datestart'];
$edate=$row['dateended'];
 
while($sdate<=$edate) {
 
echo "<option value=$sdate>$sdate</$sdate>"; 
 
$sdate =date('m/d/Y', strtotime('+1 day', strtotime($sdate)));
}
?>
Link to comment
https://forums.phpfreaks.com/topic/280927-how-to-add-date/#findComment-1444495
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.