Oihana Php Masking

maskDatetime.php

Table of Contents

Functions

maskDatetime()  : string
Replaces a value with a random date/time between two bounds, formatted.

Functions

maskDatetime()

Replaces a value with a random date/time between two bounds, formatted.

maskDatetime([mixed $value = null ][, string $begin = '1970-01-01T00:00:00.000' ][, string $end = '' ][, string $format = '' ]) : string

Implements the conventional datetime masker: a random instant is picked in [begin, end] and rendered with format. The format uses DATE_FORMAT()-style tokens — the common ones are supported: %yyyy, %yy, %mm, %m, %dd, %d, %hh, %h, %ii, %i, %ss, %s, %fff and %%. When format is empty (the default), an empty string is returned.

Parameters
$value : mixed = null

The original value (ignored — replaced wholesale).

$begin : string = '1970-01-01T00:00:00.000'

Earliest instant (ISO 8601). Defaults to the epoch.

$end : string = ''

Latest instant (ISO 8601). Empty means "now".

$format : string = ''

The DATE_FORMAT-style pattern. Empty returns "".

Tags
throws
RandomException
example
use function oihana\masking\maskDatetime;

maskDatetime( '2001-09-11' , '2019-01-01' , '2019-12-31' , '%yyyy-%mm-%dd' );
// e.g. "2019-06-17"

maskDatetime( '2001-09-11' ); // "" (no format)
since
1.0.0
author

Marc Alcaraz

Return values
string
On this page

Search results