How to Create Helper In Code-igniter (CI)

=================
date_diff_helper.php
=================

<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');
/**
 * CodeIgniter and PHPMailer integration as default CI email function will not set tls value
 *
 * @package CodeIgniter
 * @subpackage        Helpers
 * @category        Helpers
 * @author Nilesh Y, Intelliswift
 */
// ------------------------------------------------------------------------

if (!function_exists('time_diff_check')) {

    function time_diff_check($last_time) {
        if (!empty($last_time)) {
            $curent_time = date('Y-m-d H:i:s');
            $start_date = new DateTime($curent_time);
            $end_date = new DateTime($last_time);
            $interval = $start_date->diff($end_date);
            $days = $interval->days;
            return $days;
        } else {
            return 0;
        }
    }

}


/* End of file zend_framework.php */
/* Location: ./application/helpers/zend_framework_helper.php */


To Call the function use.
$this->load->helper('diff_helper');

time_diff_check($last_time);




Linux: Find Out Directory Size Command

Linux: Find Out Directory Size Command

Iam a new Linux user. How do I find out size of a directory on Linux operating systems using command line options?

You need to use the du command:
[a] Find and estimate file space usage.
Tutorial details
DifficultyEasy (rss)
Root privilegesNo
Requirementsdu
Estimated completion timeLess than a one minute
[b] Summarize disk usage of each FILE/Directory/Folder.
[c] Shows the sizes of directories and files.

Syntax

The basic syntax is:
du
du dirName
du [options] dirName

Examples

Without any options, du command shows the names and used space for each directories including all sub-directories in the current directory:
du
Sample outputs:
Fig.01: du command in action
Fig.01: du command in action
To find information about /etc and /home/nixcraft directory, enter:
du /path/to/dir
du /etc
du /home/nixcraft
du /root /home/nixcraft
Pass the -h option to get output in human readable format i.e. show output in kilobytes (K), megabytes (M) and gigabytes (G):
du -h /etc
du -h /dir1/file2
du -h /root
du -h

Sample outputs:
8.0K ./.vim
24K ./scripts
48K ./.ssh
16K ./.keychain
2.2M ./.lftp
2.4M .
Pass the -s option to see the total disk space used by a directory:
du -sh
du -sh /etc/
du -sh /etc /home/ /securebackup/

Sample outputs:
4.1M /etc
152K /home/
902M /securebackup/
Pass the -c to see a grand total for all of the files, type:
du -csh /root/ /etc/ /home/
Sample outputs:
2.4M /root/
4.1M /etc/
152K /home/
6.6M total

How to convert an entire MySQL database characterset and collation to UTF-8

First First, backup!
First, you need to set the default char sets on the database. This does not convert existing tables, it only sets the default for newly created tables.
ALTER DATABASE dbname CHARACTER SET utf8 COLLATE utf8_general_ci;
Then, you will need to convert the char set on all existing tables and their columns. This assumes that your current data is actually in the current char set. If your columns are set to one char set but your data is really stored in another then you will need to check the MySQL manual on how to handle this.
ALTER TABLE tbl_name CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
Some Usefull snippets 
ALTER DATABASE databasename CHARACTER SET utf8 COLLATE utf8_unicode_ci;
ALTER TABLE tablename CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;