sql - PHP: Time - "Today" - "Yesterday" by dates and not hours -


this question has answer here:

i got figured out:

$dates = date(" d-m-y",$forum_tid); if ($dates == date(' d-m-y')) {     $day_name = 'this day'; } else if($dates === date(" d-m-y", strtotime("-1 day"))) {    $day_name = 'yesterday'; } else {     $day_name = 'another day'; } echo "$day_name"; 

now runs 24 hours clock-system. want work dates. (if time same day, says "this day", if date before f.ex 23-08-13, shows "yesterday")

how do this? hope question more people wondering about!

with datetime class:

$date = new datetime(); $date->settimestamp($forum_tid);  $today = new datetime(); $yesterday = new datetime('-1day');  switch(true) {      case $today->format('m-d') === $date->format('m-d'):         $day_name = 'this day';     break:      case $yesterday->format('m-d') === $date->format('m-d'):         $day_name = 'yesterday';     break;      default:         $day_name = 'another day';  }  echo "$day_name"; 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -