getTimestampedDirectory.php
Table of Contents
Functions
- getTimestampedDirectory() : string
- Get a timestamped file path using a formatted date and optional prefix/suffix.
Functions
getTimestampedDirectory()
Get a timestamped file path using a formatted date and optional prefix/suffix.
getTimestampedDirectory([string|null $date = null ][, string $basePath = Char::EMPTY ][, string $prefix = Char::EMPTY ][, string $suffix = Char::EMPTY ][, string|null $timezone = 'Europe/Paris' ][, string|null $format = 'Y-m-dTH:i:s' ][, bool $assertable = true ]) : string
Combines a date/time string (or the current time) with optional *extension, prefix, suffix, and base path to generate a unique file name. The file is not created on disk.
Asserts by default if the file exist, you can disabled the behavior with the boolean assertable argument.
Parameters
- $date : string|null = null
-
Optional date/time string to use. If null or invalid, the current date/time is used ("now").
- $basePath : string = Char::EMPTY
-
Optional base path in which to place the directory. Defaults to the current directory.
- $prefix : string = Char::EMPTY
-
Optional string to prepend to the directory name (e.g., "/hello-2025-12-01T14:00:00"").
- $suffix : string = Char::EMPTY
-
Optional string to append to the directory name (e.g., "/2025-12-01T14:00:00-hello"").
- $timezone : string|null = 'Europe/Paris'
-
Timezone identifier (e.g., 'Europe/Paris'). Defaults to 'Europe/Paris'.
- $format : string|null = 'Y-m-dTH:i:s'
-
Date format compatible with DateTime::format(). Defaults to 'Y-m-d\TH:i:s'.
- $assertable : bool = true
-
Whether to validate the path with assertDirectory(). Defaults to true.
Tags
Return values
string —The full path of the generated directory.