Reference - Parms functions - localDate


App: manual - Page: fragments/locale_1
PHP
fragments/locale_1.php
HTML
fragments/locale_1.pad
Result
<?php

// The page picks Dutch; an application listing $padLocales lets the visitor's
// Accept-Language or ?lang= choose instead.

$padLocale = 'nl';

$count = 3;
$user = 'Ann';
$total = 1234.5;
$when = '2026-10-05';

?>
<h4>{trans 'cart.title'}</h4>
<p>{trans 'cart.items', count=$count} - {trans 'cart.owner', name=$user}</p>
<p>{$total | currency('EUR', 'nl_NL')} - {$when | localDate('d MMMM y')}</p>


App: regression/errors - Page: syntax/a_localDate_locale_intl_does_not_know
PHP
HTML
syntax/a_localDate_locale_intl_does_not_know.pad
Result
{echo 5 | localDate('long', 'none', 'zz')}


App: regression/framework - Page: functions/an_empty_localDate_style_is_the_default_style
PHP
HTML
functions/an_empty_localDate_style_is_the_default_style.pad
Result
[{echo '2026-10-05' | localDate('')}][{echo '2026-10-05 13:45' | localDate('long', '')}]


App: regression/framework - Page: functions/localDate_reads_a_date_in_text_in_the_application_timezone
PHP
functions/localDate_reads_a_date_in_text_in_the_application_timezone.php
HTML
functions/localDate_reads_a_date_in_text_in_the_application_timezone.pad
Result
<?php

// A date in text is read in the application's timezone, the one localDate writes it in:
// read with strtotime in the zone the request started with, 2023-11-15 01:00 came out as
// another hour, and with a zone west of that one as the day before.

$padTimezone = 'Pacific/Kiritimati';

$day = '2023-11-15';
$time = '2023-11-15 01:00';

?>
[{$day | localDate}][{$time | localDate('y-MM-dd HH:mm')}][{$time | localDate('short', 'short', 'nl')}]


App: regression/framework - Page: functions/localDate_reads_an_empty_style_as_the_default_one
PHP
HTML
functions/localDate_reads_an_empty_style_as_the_default_one.pad
Result
[{echo '2026-10-05' | localDate('', '', 'en_US')}][{echo '2026-10-05' | localDate('medium', '', 'en_US')}]


App: regression/framework - Page: functions/localDate_writes_a_date_the_locale_s_way
PHP
HTML
functions/localDate_writes_a_date_the_locale_s_way.pad
Result
[{echo '2026-10-05' | localDate('d MMMM y', 'none', 'nl')}][{echo '2026-10-05' | localDate('long', 'none', 'en_US')}]


App: regression/framework - Page: functions/local_date_writes_the_timezone_the_page_set
PHP
functions/local_date_writes_the_timezone_the_page_set.php
HTML
functions/local_date_writes_the_timezone_the_page_set.pad
Result
<?php

// The page sets its own timezone; 1700000000 is 22:13 UTC on 14 November 2023.

$padTimezone = 'Asia/Tokyo';
$t = 1700000000;

?>
{$t | localDate('yyyy-MM-dd HH:mm')}


App: regression/framework - Page: functions/the_date_pipes_follow_a_frozen_clock
PHP
functions/the_date_pipes_follow_a_frozen_clock.php
HTML
functions/the_date_pipes_follow_a_frozen_clock.pad
Result
<?php

padNowFreeze
( '2020-01-15 10:00:00' );

?>
[{echo now | date('Y-m-d')}][{echo '' | date('Y-m-d')}][{echo 'tomorrow' | date('Y-m-d')}][{echo '' | localDate('y-MM-dd')}]


App: regression/framework - Page: functions/the_date_pipes_read_the_relative_formats_of_php
PHP
HTML
functions/the_date_pipes_read_the_relative_formats_of_php.pad
Result
[{echo 'first day of december' | date('m-d')}][{echo 'february' | date('m')}][{echo '2026-10-21 24:00:00' | date('Y-m-d H:i')}][{echo '0000-00-00 00:00:00' | date('Y-m-d')}][{echo '0000-00-00' | localDate('y-MM-dd')}][{echo 'last day of february 2026' | localDate('y-MM-dd')}]


App: regression/framework - Page: lenient/a_locale_intl_does_not_know_falls_back_to_the_plain_form
PHP
lenient/a_locale_intl_does_not_know_falls_back_to_the_plain_form.php
HTML
lenient/a_locale_intl_does_not_know_falls_back_to_the_plain_form.pad
Result
<?php

// The lenient walk under test: with the syntax check off, what cannot run passes the
// value through or yields empty, and the walk carries on.

$padCheckSyntax = FALSE;

?>
[{echo 1234.5 | currency('EUR', 'xx_YY')}][{echo '2026-10-05' | localDate('long', 'none', 'zz')}]


App: regression/framework - Page: variables/a_date_object_is_a_value_for_tags_and_pipes
PHP
variables/a_date_object_is_a_value_for_tags_and_pipes.php
HTML
variables/a_date_object_is_a_value_for_tags_and_pipes.pad
Result
<?php

$padTimezone
= 'UTC';

padNowFreeze ( '2026-01-05 03:04:05 UTC' );

$when = new DateTimeImmutable ( '2026-01-02 03:04:05', new DateTimeZone ( 'UTC' ) );
$str = new class { function __toString () { return 'stringy'; } };

?>
{$when}|{echo $when}|{echo $when | date('Y-m-d H:i')}|{$when | ago}|{echo $when | ago}|{echo $when | localDate('y-MM-dd')}|{timeago $when}|{echo $str}|{if $str eq 'stringy'}T{else}F{/if}