====== Date functions ====== Like any good programming language PHP needs a way to handle dates. Theres loads of functions and ways that handle date in PHP. Heres a [[https://www.php.net/manual/en/ref.datetime.php|list]] of few important functions: * time() returns the current Unix timestamp * date() retruns a timestamp in a given format, uses time() if no timestamp is given * date_create() returns a DateTime object, it needs a datetime string and optionally a timezone. * date_date_set() sets the given date to a new one with given ints, corresponding to year, month and day * date_diff() returns the diff of 2 given DateTime objects * date_format() returns a given DateTime object in a different given format * date_modify() Alter the timestamp of a DateTime object by incrementing or decrementing in a accepted format * timezone_offset_get() gets the offset to GMT of a given date with a given timezone object ===== Datetime string parsing ===== A [[https://www.php.net/manual/en/datetime.formats.php|Date or Time string]] can be alot of things like "now", "today", "in 5 days", "first day of June 2009". Or simply It is parsed by a parser if needed and turned into a date and time of your choice. The formats and how its parsed is very interesting.