Search Results

Search found 1 results on 1 pages for 'first2drown'.

Page 1/1 | 1 

  • How does my php function for converting a date to facebook timestamp look? New to PHP.

    - by First2Drown
    any suggestions to make it better? function convertToFBTimestamp($date){ $this_date = date('Y-m-d-H-i-s', strtotime($date)); $cur_date = date('Y-m-d-H-i-s'); list ($this_year, $this_month, $this_day, $this_hour, $this_min, $this_sec) = explode('-',$this_date); list ($cur_year, $cur_month, $cur_day, $cur_hour, $cur_min, $cur_sec) = explode('-',$cur_date); $this_unix_time = mktime($this_hour, $this_min, $this_sec, $this_month, $this_day, $this_year); $cur_unix_time = mktime($cur_hour, $cur_min, $cur_sec, $cur_month, $cur_day, $cur_year); $cur_unix_date = mktime(0, 0, 0, $cur_month, $cur_day, $cur_year); $dif_in_sec = $cur_unix_time - $this_unix_time; $dif_in_min = (int)($dif_in_sec / 60); $dif_in_hours = (int)($dif_in_min / 60); if(date('Y-m-d',strtotime($date))== date('Y-m-d')) { if($dif_in_sec < 60) { return $dif_in_sec." seconds ago"; } elseif($dif_in_sec < 120) { return "about a minute ago"; } elseif($dif_in_min < 60) { return $dif_in_min." minutes ago"; } else { if($dif_in_hours == 1) { return $dif_in_hours." hour ago"; } else { return $dif_in_hours." hours ago"; } } } elseif($cur_unix_date - $this_unix_time < 86400 ) { return strftime("Yesterday at %l:%M%P",$this_unix_time); } elseif($cur_unix_date - $this_unix_time < 259200) { return strftime("%A at %l:%M%P",$this_unix_time); } else { if($this_year == $cur_year) { return strftime("%B, %e at %l:%M%P",$this_unix_time); } else { return strftime("%B, %e %Y at %l:%M%P",$this_unix_time); } } }

    Read the article

1