PHP

PHP Menu

PHP

localtime() Function - Definition, Syntax, Parameters, Examples

Definition

The localtime() function returns the local time.

Syntax

localtime(timestamp, is_assoc)

Parameters

Parameter Description
timestamp Optional. Specifies a Unix timestamp that defaults to the current local time, time(), if no timestamp is specified.
is_assoc Optional. Specifies whether to return an associative or indexed array. false = the array returned is an indexed array. true = the array returned is an associative array. false is default. The keys of the associative array are:
[tm_sec] - seconds
[tm_min] - minutes
[tm_hour] - hour
[tm_mday] - day of the month
[tm_mon] - month of the year (January=0)
[tm_year] - Years since 1900
[tm_wday] - Day of the week (Sunday=0)
[tm_yday] - Day of the year
[tm_isdst] - Is daylight savings time in effect

Example

<?php
print_r(localtime());

Introduction

PHP Basics

PHP Advance

PHP OOP

PHP Functions and Methods