<?php
$myWeek=array("Today","Yesterday");
for($i=2;$i<7;$i++){
array_push($myWeek,date('l',strtotime('-'.$i.' day')));
}
function getDayName($myDate,$myWeek){
global $myWeek; // globalise the $myWeek array
if($myDate> strtotime('-7 day')){
return $myWeek[(time()-$myDate)/(60*60*24)];
}
else{
return date('d/m/Y',$myDate); // else just return the date as a normal date string
}
}
$dayName = getDayName($yourdatetime);
$dayName = getDayName(strtotime($yourdatetime));
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (0)