#dates Clear
Tags #php #kotlin #bash #go #sql #rust #typescript #html #java #python #files #utils #strings #http #concurrency #async #json #arrays #security #types #crypto #database #dates #format
PHP Business Days Between Two Dates
Count weekdays (Mon-Fri) between two dates, excluding an optional list of holidays. Direction-aware (works even if $end < $start).
TypeScript Date Range Generator
Yield each day (or step) between two dates as a Date object. Generator-based so consumers can `break` early without computing the whole range.
Bash Format Date Like a Pro
`date` accepts a format string + optional override of the date being formatted. The +%FT%TZ form gives you ISO-8601 / RFC-3339 in one call.
TypeScript isWithinInterval — Date Range Check
Inclusive check that a date falls between two boundaries. Tiny but constantly useful for filtering rows by date range, validating bookings, etc.
Bash Epoch ↔ Human Date Conversion
`date +%s` gives now-as-epoch; `date -d @N` converts an epoch number back to a human date. Often what API responses expect / return.
SQL EXTRACT — Pull Parts Out of a Timestamp
`EXTRACT(field FROM timestamp)` pulls year, month, hour, day-of-week, week, epoch — whatever you need to group, filter, or render. Standard SQL across every database.
TypeScript Format Relative Time ("3 days ago")
Use the built-in Intl.RelativeTimeFormat to render "3 days ago" / "in 5 hours". Localized for free — pass any BCP 47 locale. No date library needed.
PHP Human-Readable "Time Ago"
Convert a timestamp into a short relative phrase: "just now", "5 minutes ago", "3 days ago". Falls back to an absolute date once the delta exceeds a year.
PHP Convert Timestamp to User Timezone
Convert a stored UTC timestamp into the viewer's timezone for display. Round-trip safe: re-converting to UTC always gives back the original timestamp.
Bash Days Between Two Dates
Convert both dates to epoch seconds, subtract, divide. Works for hours/minutes too with the obvious divisor.
SQL BETWEEN — Range Filtering
`BETWEEN a AND b` is inclusive on both ends. Cleaner than `col >= a AND col <= b`. For dates, watch for end-of-day vs midnight boundaries.
PHP Format Duration in Seconds
Render a number of seconds as a human-friendly duration like "1h 23m 45s" — automatically trimming leading zero units. Handy for elapsed-time displays in dashboards.
SQL Recursive CTE — Date Spine Generator
Generate a row per day (or month, year, hour) without a calendar table. Useful for filling gaps when a date has no events but you still want it in your output.
TypeScript Format Duration in ms
Render a number of milliseconds as a human-friendly duration: "1h 23m 45s". Skips leading-zero units automatically so short durations are concise.
PHP Date Range Iterator
Yield each date in a [start, end] interval as a DateTimeImmutable, with a configurable step. Builds on DatePeriod under the hood — but exposes a generator so you can break out early.
Bash Convert Between Timezones
Set TZ inline to print a date in a specific timezone, then read with another TZ. Avoids messing with the system timezone.
Bash Add / Subtract Time from Date
GNU date accepts natural-language deltas: "+1 day", "-3 weeks", "now + 2 hours". Combine with -d to compute against any reference date.
PHP Start / End of Day, Week, Month
Snap a DateTime to the start (00:00:00) or end (23:59:59) of its day, week, or month. Builds on DateTimeImmutable for value-safety.