An additional benefit not mentioned so far is that desirable quantization (assigning a precise value as belonging to the same general range of values) is a relatively easy and fast single operation..
Suppose you're writing a report that summarises the events today, like the sum and number of sales. The sale date and time is stored as YYYYMMDDHHMISS, you simply need to keep the leftmost 8 characters (if it's a string) or integer divide (i.e. floor) by 1,000,000 to reduce your datetime to the day of the sale.
Similarly, if you wanted the month's sales, you keep only the leftmost 6 digits, or divide by 100,000,000
Sure, you could argue that any string manipulation is possible, a datetime for sales of "12-25-2018 12:34pm" could be substringed and manipulated multiple times to get the month and the year. In numeric form 122520181234 could be divided and modded, and multiplied, and divided some more, and eventually also produce a month and a year..
..but the code would be really difficult to write, read, maintain and understand..
And even sophisticated database optimizers might not be able to make use of an index on a column for a where clause if the date form was MM/DD/YYYY but cut up and pieced back together.
In comparison, storing a YYYYMMDD representation and wanting December 2018 leads to where clauses of the ilk dateasstring LIKE '201812%'
or dateasint BETWEEN 20181200 and 20181299
- something an index can easily be used for
Thus, if there wasn't a dedicated datatype for dates and string/numerical representation was the only choice, using and storing times in some representation of longest-interval-on-the-left-to-shortest-interval-on-the-right has quite a few benefits for ease of understanding, manipulation, storage, retrieval and code maintenance
asctime
, are still widely used in a lot of places. It's nice that RFC 3339 and ISO 8601 are gradually displacing the older formats, and they're certainly what should be used going forward. More generally, I would say the ISO 8601 basic form (plain YYYYMMDD without separator characters) is actually less common than some other forms, like YYYY-MM-DD.