PHP.nl

idate

idate

Format a local time/date part as integer

 **idate** string $format  $timestamp

Returns a number formatted according to the given format string using the given integer or the current local time if no timestamp is given. In other words, is optional and defaults to the value of . timestamp``timestamp``time

Unlike the function , accepts just one char in the parameter. date``idate``format

format

Returns an on success, return.falseforfailure. int

As always returns an and as they can't start with a "0", may return fewer digits than you would expect. See the example below. idate``int``idate

Voorbeeld: example

<?php
$timestamp = strtotime('1st January 2004'); // 1072915200

// this prints the year in a two digit format
// however, as this would start with a "0", it
// only prints "4"
echo idate('y', $timestamp) . "\n";

$timestamp = strtotime('1st January 2024'); // 1704067200
echo idate('y', $timestamp);
4
24

DateTimeInterface::format``date``getdate``time