reenadak icon

Format Date Unix

reenadak | PRO | 02/20/18 06:52:32 PM UTC | 0 ⭐ | 380 👁️ | Never ⏰ | []
PHP |

520 B

|

None

|

0 👍

/

0 👎

    /*
    - Format Date (Unix)
    - Formats unix time (number of seconds passed since January 1st, 1970 to human
      readable time like "January 1, 2015 at 3:35pm"
      
    $unixTime     - The time to be formatted (current time can be fetched with the php
                    function time() )
    */
    
    public function formatDateUnix($unixTime, $dateOnly = false) {
        $formatted = date("F d, Y", $unixTime);
        
        if (!$dateOnly) {
            $formatted .= " at ";
            $formatted .= date("g:ia", $unixTime);
        }
        
        return $formatted;
    }

Comments