Reference - PAD functions - ago


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

padNowFreeze
( '2026-10-05 14:30:00' );

$comments = [
[
'author' => 'Ann', 'posted' => '2026-10-05 14:29:55' ],
[
'author' => 'Bob', 'posted' => '2026-10-05 14:12:00' ],
[
'author' => 'Cleo', 'posted' => '2026-10-04 09:00:00' ],
[
'author' => 'Dirk', 'posted' => '2026-09-20 18:00:00' ],
[
'author' => 'Eve', 'posted' => '2025-06-01' ]
];

$deadline = padAgo ( '2026-10-08 12:00' );

?>
<ul>
{comments}
<li>{$author} - {$posted | ago}</li>
{/comments}
</ul>
<p>The deadline is {$deadline}.</p>


App: regression/errors - Page: helpers/dates_ago_pipe_names_what_is_no_date
PHP
HTML
helpers/dates_ago_pipe_names_what_is_no_date.pad
Result
{echo 'whenever' | ago}


App: regression/framework - Page: custom/an_application_function_can_answer_a_date_object
PHP
custom/an_application_function_can_answer_a_date_object.php
HTML
custom/an_application_function_can_answer_a_date_object.pad
Result
<?php

$order
= 'x';

?>
[{$order | dueDate | date('Y-m-d')}][{$order | dueDate | ago('2020-01-03 03:04:05')}][{$order | dueDate}]


App: regression/framework - Page: expressions/a_nan_an_expression_makes_is_empty
PHP
expressions/a_nan_an_expression_makes_is_empty.php
HTML
expressions/a_nan_an_expression_makes_is_empty.pad
Result
<?php

$x
= 5;

?>
[{$x | php:fdiv(0, 0)}][{$x | php:fdiv(0, 0) | ago}][{if php:fdiv(0, 0)}y{else}n{/if}][{echo php:fdiv(0, 0) . 'x'}][{$x | (-8) ** (1/3)}]


App: regression/framework - Page: helpers/dates_ago_pipe_writes_a_field_in_words
PHP
helpers/dates_ago_pipe_writes_a_field_in_words.php
HTML
helpers/dates_ago_pipe_writes_a_field_in_words.pad
Result
<?php

// {$created | ago} is padAgo in a template: a timestamp, a date in text, now frozen or
// not; ago($end) counts from another moment, and an empty field has no age.

$padTimezone = 'UTC';

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

$created = '2026-01-15 09:55:00';
$stamp = padNow ()->getTimestamp () - 7200;
$start = '2026-01-01';
$end = '2026-01-02';
$empty = '';

?>
{$created | ago} / {$stamp | ago} / {$start | ago($end)} / [{$empty | ago}] / {echo '2026-01-17' | ago} / {echo 'tomorrow 08:00' | ago}


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}