Compare Dates PHP -


i want shows result current month, have no idea how this, current output this.

output

2014-04-11 -> array 2014-04-11  2014-04-05 2014-03-29 

php

$date = date('y-m-d');  echo $date;  echo "<pre>"; foreach ($submissions $test){     if($date >=  substr($test['thing']['created'], 0, 10)){         echo substr($test['thing']['created'], 0, 10);         echo "<br>";     } } echo "</pre>"; 

my current code wont work checking if whole number greater or equal to, ideas anyone?

just try strtotime:

$year  = date('y'); $month = date('m');  foreach ($submissions $test) {   $timestamp = strtotime($test['thing']['created']);   $testyear  = date('y', $timestamp);   $testmonth = date('m', $timestamp);    if (($month >= $testmonth && $year == $testyear) || $year > $testyear) {     // test passed   } } 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -