Oihana PHP

now.php

Table of Contents

Functions

now()  : string
Returns the current date/time as a formatted string.

Functions

now()

Returns the current date/time as a formatted string.

now([string $timezone = 'UTC' ][, string|null $format = 'Y-m-dTH:i:s.vZ' ]) : string
Parameters
$timezone : string = 'UTC'

The timezone identifier (e.g., 'Europe/Paris'). Defaults to 'UTC'.

$format : string|null = 'Y-m-dTH:i:s.vZ'

The date format string compatible with DateTime::format(). Defaults to 'Y-m-d\TH:i:s.v\Z' (ISO 8601 UTC with milliseconds).

Tags
throws
DateInvalidTimeZoneException

If the provided timezone string is invalid.

throws
DateMalformedStringException

If the date creation fails (should not occur with 'now').

example
echo now() ;
// Output: '2025-07-20T15:30.676Z'
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
string

The formatted current date/time string.


        
On this page

Search results