0

How install and use Xajax 0.6 beta 1 on Codeigniter 2.0+ ?

Do not use the 0.6 version on Github as it causes:

Warning: file_put_contents(K:DreamWebSitesxAjax/xajax_js/deferred/7b5d4816861867bcd00d0bc0466be45b.js) [function.file-put-contents]: failed to open stream: No such file or directory in K:DreamWebSitesxAjaxxajax_corexajaxPluginManager.inc.php on line 588

 

  1. Download and install Xajax 0.6 beta 1 from xajax-project.org
  2. move contents of xajax_core into application/libraries/
  3. rename xajax.inc.php to xajax.php
  4. put the xajax_js folder in root folder where CI is installed. (where the /application/ /system/ license.txt are)
  5. follow step 6 onwards from: http://www.gen.newrandom.com/2011/07/21/codeigniter-and-xajax-csrf-fix/
  6. You may skip 7 onwards if not using CSRF.
facebooktwittergoogle plus

0

How to convert seconds into days hours minutes in PHP? (Time elapsed, just now, ago)

Use example :

echo time_elapsed_string('2013-05-01 00:22:35');
echo time_elapsed_string('@1367367755');# timestamp input
echo time_elapsed_string('2013-05-01 00:22:35',true);

Input can be any supported date and time format.

Output :

4 months ago
4 months,2 weeks,3 days,1 hour,49 minutes,15 seconds ago

Function :

function time_elapsed_string($datetime, $full =false){
    $now =newDateTime;
    $ago =newDateTime($datetime);
    $diff = $now->diff($ago);

    $diff->w = floor($diff->d /7);
    $diff->d -= $diff->w *7;

    $string = array('y'=>'year','m'=>'month','w'=>'week','d'=>'day','h'=>'hour','i'=>'minute','s'=>'second',);foreach($string as $k =>&$v){if($diff->$k){
            $v = $diff->$k .' '. $v .($diff->$k >1?'s':'');}else{
            unset($string[$k]);}}if(!$full) $string = array_slice($string,0,1);return $string ? implode(', ', $string).' ago':'just now';}

 

http://stackoverflow.com/questions/1416697/converting-timestamp-to-time-ago-in-php-e-g-1-day-ago-2-days-ago/18602474#18602474

facebooktwittergoogle plus