Junior
What date and time functions do you know?
sobes.tech AI
Answer from AI
date(): Formats local date and time.strtotime(): Converts a date/time string to a Unix timestamp.mktime(): Returns the Unix timestamp for a given date.time(): Returns the current Unix timestamp.getdate(): Returns an associative array of date and time information.idate(): Formats local time/date as an integer.gmdate(): Formats date/time in Greenwich Mean Time based on Unix timestamp.gmstrftime(): Formats Greenwich Mean Time date/time according to locale settings.setDate(): Sets the date for aDateTimeobject.setTime(): Sets the time for aDateTimeobject.setTimestamp(): Sets the Unix timestamp for aDateTimeobject.add(): Adds aDateIntervalto aDateTimeobject.sub(): Subtracts aDateIntervalfrom aDateTimeobject.diff(): Returns the difference (DateInterval) between twoDateTimeobjects.
I also actively use classes DateTime, DateTimeImmutable, and DateInterval for more object-oriented work with dates and times. For example:
<?php
// Creating a DateTime object
date = new DateTime('now');
echo $date->format('Y-m-d H:i:s');
// Adding an interval
$interval = new DateInterval('P1D'); // Add 1 day
$date->add($interval);
echo $date->format('Y-m-d H:i:s');