Select Page
Facebook style time ago function PHP

Facebook style time ago function PHP

Here i have added that function snippet.It quite useful for social networking web development.you can use this function to your helper component .

<?php

function time_elapsed_string($datetime, $full = false) {
        $today = time();    
                 $createdday= strtotime($datetime); 
                 $datediff = abs($today - $createdday);  
                 $difftext="";  
                 $years = floor($datediff / (365*60*60*24));  
                 $months = floor(($datediff - $years * 365*60*60*24) / (30*60*60*24));  
                 $days = floor(($datediff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));  
                 $hours= floor($datediff/3600);  
                 $minutes= floor($datediff/60);  
                 $seconds= floor($datediff);  
                 //year checker  
                 if($difftext=="")  
                 {  
                   if($years>1)  
                    $difftext=$years." years ago";  
                   elseif($years==1)  
                    $difftext=$years." year ago";  
                 }  
                 //month checker  
                 if($difftext=="")  
                 {  
                    if($months>1)  
                    $difftext=$months." months ago";  
                    elseif($months==1)  
                    $difftext=$months." month ago";  
                 }  
                 //month checker  
                 if($difftext=="")  
                 {  
                    if($days>1)  
                    $difftext=$days." days ago";  
                    elseif($days==1)  
                    $difftext=$days." day ago";  
                 }  
                 //hour checker  
                 if($difftext=="")  
                 {  
                    if($hours>1)  
                    $difftext=$hours." hours ago";  
                    elseif($hours==1)  
                    $difftext=$hours." hour ago";  
                 }  
                 //minutes checker  
                 if($difftext=="")  
                 {  
                    if($minutes>1)  
                    $difftext=$minutes." minutes ago";  
                    elseif($minutes==1)  
                    $difftext=$minutes." minute ago";  
                 }  
                 //seconds checker  
                 if($difftext=="")  
                 {  
                    if($seconds>1)  
                    $difftext=$seconds." seconds ago";  
                    elseif($seconds==1)  
                    $difftext=$seconds." second ago";  
                 }  
                 return $difftext;  
    }

?>

you can call this function with date time parameter

<?php
time_elapsed_string('2013-10-20 17:15:20')
?>

facebook

PHP FRAMEWORK CODEIGNITOR

PHP FRAMEWORK CODEIGNITOR

Codeigniter is a commanding PHP framework. If we consider web applications with advanced features, then to create such an application Codeigniter is one of the efficient PHP Frameworks. As it makes web application always ready, learning becomes easier. Also due to the usual PHP coding it makes the code portable and only because of this, Compared to other frameworks, CodeIgniter is significantly simple and fast.

Advantages

  • Easy and hassle-free migration from server hosting to server hosting.
  • Easy to learn, adopt and deploy.
  • Easy handling and customizing.
  • A new functionality has been applied without affecting the customization at all.
  • Offers flexibility and easy management With MVC based framework.
  • Active Record Implementation is simply superb and easy to remember.
  • Provides easier configuration and customization of configuration files.
  • Facilitates easy working with a variety of developers.
  • Good collection of possessed libraries.
  • Awesome documentation of the user guide, which makes it easy for any coder to use the whole framework.
  • Enables to incorporate its own existing scripts as well as develop core libraries for the system.
  • Lightweight and extensive Thai user base.

Disadvantages

  • Its PHP based only and not very object-oriented in some parts
  • PHP4 legacy code
  • Company-driven instead of community-driven
  • Irregular releases
  • Framework itself has no built-in ORM (only via 3rd party solutions).

Benefits Of CodeIgnitor

  • A small track and astounding presentation
  • Provision of broad compatibility along with standard hosting accounts
  • Configuration and normal coding rules are not required
  • Depiction of straightforward solutions
  • Free from complex structures and development