Search results
If you are returning the seconds from MySQL database, assuming you don't need the data in seconds format in your app, there is a much cleaner way to do it, you can use MySQL's SEC_TO_TIME and it will return time in hh:mm:ss format.
Note that date() will always generate 000000 since it takes an int parameter, whereas DateTimeInterface::format() does support microseconds if an object of type DateTimeInterface was created with microseconds.
15 mar 2013 · The date_format() function returns a date formatted according to the specified format. Note: This function does not use locales (all output is in English). Tip: Also look at the date() function, which formats a local date/time.
Time Formats. This page describes the different date/time formats in a BNF-like syntax, that the DateTimeImmutable, DateTime, date_create(), date_create_immutable(), and strtotime() parser understands. To format DateTimeImmutable and DateTime objects, please refer to the documentation of the DateTimeInterface::format() method.
The required format parameter of the date() function specifies how to format the date (or time). Here are some characters that are commonly used for dates: d - Represents the day of the month (01 to 31) m - Represents a month (01 to 12) Y - Represents a year (in four digits) l (lowercase 'L') - Represents the day of the week
3 gru 2012 · You can have both formats as an argument to the function date(): date("d-m-Y H:i:s") Check the manual for more info : http://php.net/manual/en/function.date.php. As pointed out by @ThomasVdBerge to display minutes you need the 'i' character
Use the DateTimeImmutable class, and its DateTimeInterface::format () formatting method to format date/time information with a timezone attached. Format accepted by DateTimeInterface::format ().