Welcome to WebmasterWorld Guest from 23.22.140.143

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Month if condition meet

if condition

     
1:01 pm on Jun 3, 2010 (gmt 0)

Junior Member

5+ Year Member

joined:July 24, 2009
posts: 113
votes: 0


hi,

Any idea how to use the if condition eg: if my timestamp fall on june hours minutes and second? i tried on the date('m') but it didn't work.


//MONTH (june)
$timestamp = time();
$month_start_time = strtotime("june 00:00:00");
$month_end_time = strtotime("june 23:59:59");
$date = time();

if (date('m') == date('m',strtotime('june'))) {

$data = mysql_query("SELECT `items` FROM `log` where `timestamp` >= '".$month_start."' AND `timestamp` <= '".$month_end."'")
or die(mysql_error());
$month=mysql_num_rows($data);

Print "<tr>";
Print "<td class='userbg'><font class='userft'>Order : $month</font></td></tr>";

} else {
Print "No Order";
Print "</table>";
print "\n";
}

2:22 pm on June 3, 2010 (gmt 0)

Junior Member

5+ Year Member

joined:Nov 14, 2006
posts:172
votes: 0


The solution, at least not the simplest is not in PHP itself but in MySQL, try this query:

SELECT items 
FROM log
WHERE DATE_FORMAT( FROM_UNIXTIME(timestamp), '%m' ) = 6


I presumed "timestamp" is a real UNIX timestamp, if it is not just remove "FROM_UNIXTIME".
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members