Convert UNIX Timestamp to Date
Converts a UNIX timestamp to formatted date strings with an explicit timezone.
Open SnippetPractical pure PHP patterns that are easy to study, adapt and use.
Converts a UNIX timestamp to formatted date strings with an explicit timezone.
Open SnippetParses a date string in an explicit timezone and returns its UNIX timestamp.
Open SnippetCalculates the difference between two dates and returns days, hours, minutes, and direction.
Open SnippetRuns a regular expression match and returns the first matched value when the pattern is valid.
Open SnippetReplaces text with preg_replace() and reports whether the regular expression completed successfully.
Open SnippetSets a cookie with explicit expiry, path, secure, HttpOnly, and SameSite options when headers are still open.
Open SnippetReads a named cookie from $_COOKIE and returns a trimmed string value only when it exists.
Open SnippetDeletes a cookie by queuing an expired Set-Cookie header with matching path and safety options.
Open SnippetRegisters a temporary custom error handler that captures safe error details into an array and restores the previous handler.
Open SnippetTriggers a user-level warning only after validating that the supplied message is safe and non-empty.
Open SnippetUses try-catch around a risky operation and returns either the parsed value or a safe public error message.
Open SnippetDefines a focused custom exception class with a safe public message and catches it without leaking internal details.
Open Snippet