Calendars, Time & Bugs: Y2K, Y2004, Y2038, Y2106, Y4K

caveat: this web page was created before Wikipedia which I consider a better source of information than this modest effort

UTC (Universal Time Coordinated)

Before the age of internet connectivity...

 But internet connectivity changed everything...

NTP (Network Time Protocol)

NTP is an Internet service first developed in 1985 where computer systems can take on the roles of: CLIENT, SERVER or PEER
{{{ deleted a bunch of stuff }}}

Caveat: this article was created before Wikipedia (better to use: https://en.wikipedia.org/wiki/Network_Time_Protocol)

Daylight Savings Time

Indian Wisdom
 

Solaris (a flavor of Unix created by Sun Microsystems)

This company's name came from the fact that many of the principal people involved came from Stanford University (SUN)

Update: 2020-04-03

VAX / VMS System Time

Caveat: this TOY stuff is only relevant to VAX. Not Alpha, Itanium or x86-64

TOY (Time-Of-Year Clock)

Info derived from P.254 of:
Version 4.4 VAX/VMS Internals and Data Structures
(c) 1988 by Digital Equipment Corporation.

TOY Clock Notes:

Table Legend:

TOYCPR Time Of Year Clock In Processor Register
TOYCC Time Of Year Clock In Console
WC Watch Chip
BB Battery Backup

Processor TOYCC? TOYCPR? WC?
MicroVAX I N N N
MicroVAX II N N Y +BB
VAX-11/730 N Y opt BB N
VAX-11/750
VAX-11/780-782-785
VAX-8600-8650
N Y +BB N
VAX-8200
VAX-8300
N Y Y +BB
VAX-8500-8550
VAX-8700
VAX-8800
Y +BB N N

TIMEKEEPING in VAX/VMS

Info derived from P.255-256 of:
    Version 4.4 VAX/VMS Internals and Data Structures
    (c) 1988 by Digital Equipment Corporation.
When a non VAXcluster VAX/VMS system is booting, SYSINIT runs routine EXE$INIT_TODR to check the contents of the Time-Of-Year (TOY) Clock to see if it contains a value greater than hex $10000000. When the system is either started up or shut down, the $SETIME routine is called to make sure that both the Time-Of-Year Clock and the associated date entry in the system image file (SYS$SYSTEM:SYS.EXE) are accurate. When the value in the Time-Of-Year Clock is too large, its contents are lowered by one year while the stored value of the system image file are increased by a year.

What's up with "November 17, 1858" ?

caveat: 32-bit VAX-VMS is gone while 64-bit OpenVMS is in decline. However, the contents of the DEC teck-tip remain valid

PRODUCTS:  OpenVMS VAX, All Versions
           OpenVMS Alpha, All Versions
           VAX VMS, All Versions
COMPONENT: System Time
SOURCE:    Digital Equipment Corporation
QUESTION:  Why is Wednesday, November 17, 1858 the base time for OpenVMS (VAX VMS)?
ANSWER:    November 17, 1858 is the base of the Modified Julian Day system.

The original Julian Day (JD) is used by astronomers and expressed in days since noon January 1, 4713 B.C. This measure of time was introduced by Joseph Scaliger in the 16th century. It is named in honor of his father, Julius Caesar Scaliger (note that this Julian Day is different from the Julian calendar named for the Roman Emperor Julius Caesar!).

Why 4713 BC? Scaliger traced three time cycles and found that they were all in the first year of their cycle in 4713 B.C. The three cycles are 15, 19, and 28 years long. By multiplying these three numbers (15 * 19 * 28 = 7980), he was able to represent any date from 4713 B.C. through 3267 A.D. The starting year was before any historical event known to him. In fact, the Jewish calendar marks the start of the world as 3761 B.C. Today his numbering scheme is still used by astronomers to avoid the difficulties of converting the months of different calendars in use during different eras.

So why 1858? The Julian Day 2,400,000 just happens to be November 17, 1858.

The Modified Julian Day uses the following formula:

    MJD = JD - 2,400,000.5

The .5 changed when the day starts. Astronomers had considered it more convenient to have their day start at noon so that nighttime observation times fall in the middle. But they changed to conform to the commercial day.

The Modified Julian Day was adopted by the Smithsonian Astrophysical Observatory (SAO) in 1957 for satellite tracking. SAO started tracking satellites with an 8K (non-virtual) 36-bit IBM[R] 704 computer in 1957, when Sputnik was launched. The Julian day was 2,435,839 on January 1, 1957. This is 11,225,377 in octal notation, which was too big to fit into an 18-bit field (half of the IBM standard 36-bit word). And, with only 8K of memory, no one wanted to waste the 14 bits left over by keeping the Julian Day in its own 36-bit word. However, they also needed to track hours and minutes, for which 18 bits gave enough accuracy. So, they decided to keep the number of days in the left 18 bits and the hours and minutes in the right 18 bits of a word.

Eighteen bits would allow the Modified Julian Day (the SAO day) to grow as large as 262,143 ((2 ** 18) - 1). From Nov. 17, 1858, this allowed for seven centuries. Using only 17 bits, the date could possibly grow only as large as 131,071, but this still covers 3 centuries, as well as leaving the possibility of representing negative time. The year 1858 preceded the oldest star catalog in use at SAO, which also avoided having to use negative time in any of the satellite tracking calculations.

This base time of Nov. 17, 1858 has since been used by TOPS-10, TOPS-20, and VAX VMS and OpenVMS. Given this base date, the 100 nanosecond granularity implemented within OpenVMS and the 63-bit absolute time representation (the sign bit must be clear), OpenVMS should have no trouble with time until:

    31-JUL-31086 02:48:05.47

At this time, all clocks and time-keeping operations in OpenVMS will suddenly stop, as system time values go negative.

Note that the OpenVMS time display and manipulation routines allow for only 4 digits in the 'YEAR' field. We expect this to be corrected in a future release of OpenVMS sometime prior to 31-DEC-9999.

Calendar Evolution (how the Y2K problem came to be)

During the time of Caesar Augustus, astronomers in Egypt and Rome thought the length of year was 365.25 days so the new Roman calendar instituted a leap year every four years. The actual length of the solar year is closer to 365.2422 days which means the primary leap year rule is wrong.

jump to: Gregorian Calendar
Caveat: Twenty years after creating this web page, I stumbled onto this better "all-in-one-place" article: http://physics.nist.gov/time (A Walk Through Time - The Evolution of Time Measurement through the Ages)

Calendar Kinds: a 3,000 meter (10,000 foot) view

Lunar Calendars

Many ancient peoples, including Babylonians, Jews, Muslims, and Chinese, based their calendars upon the cycles of the moon. Some problems with lunar calendars include:
  1. the true year (the length of time required for the Earth to orbit the Sun) is not a whole number of lunar months. A 12 month lunar year is too short while a 13 month is a little closer to the mark
  2. the lunar orbit around the Earth is elliptical rather than circular (and the ellipse orbits slowly over the course of ~ 19 years)
By the way, the word Month comes from the word Moon (e.g. "Moonth")

Solar Calendars

Other cultures, such as the Egyptians, based their calendars on the cycles of the sun. The problem with ancient solar calendars is that the true year is not a whole number of days.

Click here to examine four popular calendars (two lunar, two solar)

Egypt ~ 4231-2773 BC

Ancient Egyptians began numbering their years when Sirius (the dog star) rose at the same place as the Sun. The Egyptian calendar was the first solar calendar and contained 365 days. These were divided into twelve 30-day months followed by five days of festival. From astronomical calculations, Sirius and the Sun coincided in 4241 BC and 2773 BC, so either of these could have served as Egyptian Year 1.

Greece ~ 440 BC

The calendar used by the ancient Greeks was based on the Moon, and is known as the Metonic calendar. This calendar was based on the observations of Meton of Athens (432 BC), who showed that 235 lunar months made up almost exactly 19 solar years. This 19-year cycle became known as the Metonic Cycle. However, given a nominal twelve-month year, and additional lunar months needed to be added to synchronize the cycle. These were added in years 3, 5, 8, 11, 13, 16, and 19 of the cycle. (note: year gap sizes are: 2-3-3-2-3-3)

Greece ~ 325 BC

Callippus (330 BC) modified the calendar by noting that four 19-year Metonic cycles with 940 months were very close to 27,759 days. This is called the Callipic Cycle. Hipparchus noted that an even more accurate cycle (now called the Hipparchic Cycle) consisted of four Callipic Cycles less a day, in which ((4 x 27759)-1) days were very nearly 3760 months. However, neither system was widely used. A lunar-based calendar is still used by some religious sects to determine holidays. Easter, for instance, generally occurs on the first Sunday following the first Full Moon after the Vernal Equinox.

Greece ~ 200 BC

In 1901, a planetarium-calendar device, now called the Antikythera Mechanism, was recovered from a Roman shipwreck circa 65 BC off the Greek island of Antikythera. It is believed to have been designed by either Hipparchus (190-120 BC) or Archimedes (287-212 BC). By turning a handle, three displays are put into motion.

  1. Single Dial Side
    • Planetarium: Displays the position of the Sun, Moon, and five planets (Mercury, Venus, Mars, Jupiter and Saturn) are displayed.
      • The Moon pointer changes speed reflecting the moon's elliptical orbit)
      • The individual planetary pointers will occasionally move backwards reflecting retrograde motion
  2. Dual Dial Side
    1. Calendar:
      • Displays 235 lunar months over 19 years
      • The Callippic Dial is the left secondary upper dial, which follows a 76-year cycle, quadrupling the Metonic dial
      •  The Olympiad Dial is the right secondary upper dial for determining the dates of the Olympic games
    2. Eclipse Predictor: both lunar and solar
Links:

The Pragma of Rome

Rome - 753 BC

Ancient Rome's calendar was neither lunar or solar, it was agricultural. It consisted of ten lunar months, beginning with the spring moon in March and ending 304 days later in December (the tenth month). The period between December and March was disregarded since no agricultural activity was possible during those 60 winter days. In keeping with an ancient custom, each month was divided into three sections known as Kalends, Nones and Ides, each of different lengths. The word Kalends, meaning a "calling" or announcement of a new month, gave us the word calendar. The Nones was nine days before the Ides. Since this Romans used inclusive counting, this day was always on the 5th or 7th of the month. The start of the calendar was chosen every year so that the Ides (either the 13 or 15 day) of each month would always land on a full moon. Months in this calendar consisted of only odd numbered days (29 or 31) because superstitious Romans tended to avoid even numbers whenever possible.

Rome - 304 BC

Proposed by Numa Pompilius (reign 715-673 BC) but not published until 304 BC (this date is in dispute), the number of months was increased from ten to twelve by adding January and February. (January comes from the two faced god Janus who simultaneous looks ahead and back). The months were still lunar in character, their lengths alternating between 29 and 30 days. This gave the year 354 days but as the total was an even number and to the Romans this was unlucky, an extra 355th day was added at the end of the year. After being advised by his astronomers that the extra 355th day would not be sufficient to agree with the seasons which were important to both agriculture and military operations, Numa inserted an additional thirteenth month every two years, calling it Mercedonius (from the Latin word for wages, indicating that it meant extra remuneration). This "remunerative" month of 22 or 23 days was arbitrarily thrust into the calendar toward the end of February, after the 23rd, when the newly inserted month began. When it was finished, the remaining five or six days of February carried on. Of all the complicated man-made calendar adjustments in history, this was certainly the most fantastic.

Rome - 45 BC (the calendar moves to 365.25 days)

Proposed by Julius Caesar in 45 BC and slightly modified thereafter by Caesar Augustus (Octavian), this calendar agrees with the Egyptian solar calendar and even implements a leap year (by adding an extra day to February) every 4 years so the calendar is synchronized with the heavens (almost). The months of Quintilis (fifth) and Sextilis (sixth) were renamed to July (after Julius who was born in that month) and August (after Augustus). January was made the first month so August would become the 8th month (because Augustus' given name was Octavian). This is why "September (septem = latin prefix for 7) through to December (decem = latin prefix for 10)" appear to be misnamed.
Solar Calendar Before Julius Caesar
(leap month every two years)
Martius (March ) 31 days Aprilis (April ) 29 days Maius (May ) 31 days Junius (June ) 29 days Quintilis (July ) 31 days Sextilis (August ) 29 days 7th month (September) 29 days 8th month (October ) 31 days 9th month (November ) 29 days 10th month (December ) 29 days 11th month (January ) 29 days 12th month (February ) 28:23:24 Mercedonius (wages ) (22-23) -------- 366 days
Solar Calendar After Julius Caesar
(leap day every fourth February)
Martius (March ) 31 days Aprilis (April ) 30 days Maius (May ) 31 days Junius (June ) 30 days Julius (July ) 31 days Augustus (August ) 31 days 9th month (September) 30 days 10th month (October ) 31 days 11th month (November ) 30 days 12th month (December ) 31 days 1st month (January ) 31 days 2nd month (February ) 1+28 days
----------- 365.25 days
 

Nicaea - 325 AD

Easter was originally linked to Passover, but in the year 325 AD, the council at Nicaea (under the Roman emperor Constantine) decided that Easter would be celebrated on the first Sunday following the first full moon, on or after the vernal equinox (the passing from winter into spring). In the year 325 AD, the vernal equinox was assumed to be fixed at March 21.

Rome - 523 AD (years change from AUC to AD)

At this time it was customary to count years since the founding of Rome (ab urbe condita or AUC) and "the church was using an Easter calculation algorithm which was about to come to an end". Around 523 AD, the papal chancellor, Bonifatius, asked monk Dionysius Exiguus (Denis the Little) to devise a new method to calculate Easter.  Information from many sources seem to indicate that Dionysius was aware that a 532 year variation (see note: 1) of the Metonic Cycle was conveniently restarted near the birth of Christ. Since only pagan cultures celebrated birthdays, Dionysius Exiguus was more concerned with the mathematical beauty of the Metonic-Callipic intersection rather than determining the birth-date of Jesus Christ. So his main claim to fame was to change the numbering of years from AUC to a date near the birth date of Jesus Christ (Anno Domini, "in the year of our Lord") only for the purposes of publishing a new Easter algorithm.
Notes:
  1. The variation of the Metonic Cycle works like this:
    1. 19 years (the Metonic Cycle)
    2. 4 years (the Callipic Cycle helps to account for leap years)
    3. 7 days in a week (Easter must fall on a Sunday)
    4. result: 532 years = 19 x 4 x 7
  2. The beginning of this cycle falls on January 754 AUC which Dionysius renamed to 1 AD
  3. Most people I talk to are still surprised by this level of detail from ancient times. But since "the proof of the pudding is in the tasting" then search for the phrase "golden number" in any of the Easter algorithms listed here
    note: the calculations always begin with: "G = year / 19" and are valid back to 1 AD

Rome - 1582 AD

year days
solar 365.2422
average calendar 365.2425

Neapolitan astronomer Aloysius Lilius noticed that the Julian calendar (which had a leap year every 4 years) was too long by almost 11 minutes per year which translated into a discrepancy of approximately 9.5 days by the year 1582. In order to make the calendar synchronize with the heavens, he suggested that centuries which are evenly divisible by 100 should not be leap years except those which are evenly divisible by 400.

Easter was originally linked to Passover, but in the year 325 AD at the council at Nicaea, it was decided that Easter would be celebrated on the first Sunday following the first full moon on, or after, the vernal equinox (the passing from winter into spring). In the year 325, the vernal equinox was assumed to be fixed at March 21. Due to inaccuracies in the calendar, by the 16th century the vernal equinox was occurring on March 11. This caused problems for the church in Rome because most Christians outside of Rome were using the date "March 21" to calculate the day of Easter rather than the "vernal equinox" event. (sometimes bad weather combined with a lack of local astronomers made "the calendar option" the only choice). This had the effect of pushing the day of Easter celebration closer to the summer months.

Pope Gregory XIII assigned the problem to a Jesuit astronomer named Christopher Schlussel (a.k.a. Clavius) who suggested that the Easter/equinox problem could be solved by removing 10 days from the current year (shifting the vernal equinox back to March 21) and adopting the suggestion proposed by Aloysius Lilius. The plan was approved by Pope Gregory approved the plan in 1582 and decreed that October 4 was followed by October 15. The peasants revolted thinking that their lives had been shortened by that much. The new calendar was named the Gregorian Calendar after the pope who approved the changes.

This so-called "continental calendar" wasn't adopted by England, or its colonies including America, until 1752. At that time, 11 days needed to be removed. (10 for the original correction, 1 for the century following)

Note: This is the reason why many Eastern European countries celebrate Christmas on Jan-6 even though Christmas has nothing to do with Christianity but more to do with "the Winter Solstice coupled with Paganism (bringing in evergreen trees indoors)" and/or Saturnalia (visiting the homes of friends with small gifts and sweet treats)

Facts:
  1. The Earth requires 365.2425 mean solar days (averaged over 4 years) for one revolution around the sun, not 365.25 as is commonly believed
  2. This difference translates into ~ 648 seconds per year which needed to be removed to correct for Easter as defined in 325 AD

Computer Calendar Bugs

Year 2000 Problem (a.k.a. the Y2K Problem)

Part 1: Short Field Storage (a.k.a. lazy programming)
God hits the RESET button (but the problem was really caused by man)
God hits the RESET button.
(but the problem was caused by man)
When dealing with dates, many programmers decided to only code for, and store, the least two significant digits of the year. This started with early mainframe programmers (1950s-1970s) who only had 80 columns of storage on each punched card. This tradition was continued on minicomputers (1970s-1980s) and PCs because memory and storage were still very expensive. There is no need to do this now.

True Fact: In 1989 a woman in who was born in 1884 was placed on a Kindergarten enrollment list because her 2-digit birthday (89) indicated that she was 5 years old rather than 105.

Now imagine the problems on January 1, 2000 when automated programs...

  1. decide to purge seemingly stale records
  2. decide to compute negative interest values
  3. decide to lock-out seemingly expired credit cards?
Other Stuff (cheap vs. lazy)

Although most currently supported operating system software has been fixed, much application software, and firmware associated with old hardware, are still broken. Unsupported software (like MS-DOS) and obsolete firmware (like PC BIOS before 1995) will probably never be fixed. Furthermore, application software that makes direct BIOS calls to check the date instead of calling a similar routine in the operating system is at great risk since the application software will only fail on certain platforms.

If (for productivity reasons) your users only enter 2 digit years, programmers should translate these dates to 4 digits for storage. Failure to do this means this problem will be back in the year 2100. 

Part 2: Is 2000 AD a Leap Year? (Yes)
Rules Divide
By
Description Remark
1 4 If a year is evenly divisible by 4 then it is a leap year.
Using this rule, 2000 AD is a leap year.
Everyone knows this rule
2 100 If a year is evenly divisible by 100 then it is not a leap year.
Using this rule, 2000 AD is not a leap year.
Many people seem to know this exception
3 400 If a year is evenly divisible by 400 then it is a leap year.
Using this rule, 2000 AD is a leap year (which is true).
Few people seem to know this exception to the exception
4 4000 If a year is evenly divisible by 4000 then that year is not a leap year Proposed

Y2004 Problem

Some Unix systems and some "C" programs will hit a wall on Saturday 2004-01-10. The reason for this is the fact that these 32 bit clocks record the number of seconds that have elapsed since 1970-01-01 (start of the Unix epoch). In some instances vendors only used 29 bits which means that we will experience (2^30 = 1,073,741,824 seconds) ~34.025 years of range before we overflow.

Y2010 Problem

It's only been 10 years since Y2K and yet, some bozo programmers didn't learn the lesson. Now we've got problems with portable devices running WindowsCE along with other stuff.

Links:

y2k20 Problem

Y2038 Problem (and Y2106 Problem)

Many Unix systems and C/C++ programs using the "time_t" or "time_b" structures will hit a wall on Monday 2038-01-18. The reason for this is the fact that these 32 bit clocks record the number of seconds that have elapsed since 1970-01-01 (start of the Unix epoch).

  1. If the 32-bit clock location was treated as a signed integer, then there are only (2^31 = 2,147,483,648 seconds) ~68.051 years of range before we overflow. 1970 + 68 = 2038. BTW, the exact rollover date is: 3:14:08 AM (GMT) on January 19, 2038
    • caveat: some older user software depends upon the fact that negative numbers can be used to represent a limited number of dates before the Unix epoch. This stuff must be renovated ASAP
  2. If the 32-bit clock location was treated as an unsigned integer, then there are only (2^32 = 4,294,967,296 seconds) ~136.103 years of range before we overflow. 1970 + 136 = 2106.
Notes:
  1. I am convinced that "C" libraries and related OS calls will be modified to either 32-bit unsigned or 64-bit before 2038. According to this article, https://en.wikipedia.org/wiki/Year_2038_problem Linux already has fixed this problem which is probably one reason why Linux is found in the data centers of most banks and insurance companies.
     
  2. I wonder how much embedded "C" software will still be working in bank machines, credit card readers, and PC BIOS firmware?

Y4K Problem?

It was suggested by the astronomer John Herschel (1792-1871) among others, that a better approximation to the length of the tropical year would be 365 x 969 / 4000 days = 365.24225 days. This would dictate 969 leap years every 4000 years, rather than the 970 leap years mandated by the Gregorian calendar. This could be achieved by dropping one leap year from the Gregorian calendar every 4000 years, which would make years divisible by 4000 non-leap years. This rule has, however, not been officially adopted.

Programmer's Summary:
  1. Never take chances. Always call operating system routines rather than doing the date calculations yourself. The operating system software designers have consulting astronomers on staff to assist in this sort of thing. They will almost always do a better job of this stuff than the little guy.
     
  2. BIOS routines are written in firmware. Operating Systems are written in software. Since the BIOS routines may be broken but the operating system may be fixed, never call the BIOS directly, Always call the operating system routines.
Advice to System Managers and System Operators:

For some reason, it is currently considered COOL to make one the following statements... What many people fail to realize is that, in most cases, new software can make up for inadequate hardware. Whenever possible, 32-bit Windows will replace calls to 16-bit BIOS routines with 32-bit alternatives. The routine for your clock chip can also be replaced but only if you have installed new OS software.

Date/Time Stamps (and displays)

How many times have you seen a date of the form 5/10/97 and thought to yourself "is that May 10th or October 5th?". It seems that Americans prefer mm/dd/yy while Brits prefer dd/mm/yy and the remainder of Europe prefers yy/mm/dd. Canadians are so confused they'll use anything. Does anyone know what this 05/06/07 means?

IMHO, the whole world should start to use a variation of the metric format ISO-8601 (sometimes called Star Trek Time) which has the following rules:
1. the most significant field (year) appears first while the least significant field (day) appears last. Similar to the odometer in your car.

2. By removing any slashes, everyone will automatically know which time format is being used. The lack of slashes will also allow the string to be used in computer file names. Some computer file systems (Unix) will allow more than one period in the file name.

3. Leading zeros must always be used to pad fields (e.g. month must be 05 not just 5)
Links:

13 Month Calendar?

It's too bad that many people in the Christian world remain superstitious because a 13-month calendar would be more efficient.
 7 days *  4 weeks  =  28 days per month
28 days * 13 months = 364 days per year

Since the length of a real year on planet Earth is 365.24 days, the 13th month would have 29 days except on leap year when it should have 30.

With a standard 28 days per month it would be easier for businesses and governments to do monthly economic forecasts. Since western workers usually skip between 2-4 work days near the end of December (Christmas, Boxing Day, etc.), this month would be the best candidate to extend by one or two days.

The 13 month calendar would be better for anyone paid once or twice monthly.

DST07 (Daylight Savings Time 2007)

Back in 2005, the Bush/Cheney Administration (USA) thought they could save some energy starting in 2007 by shifting the beginning of DST from the first Sunday in April to the second Sunday in March (advanced by 3 weeks). They also decided to end DST one week later by moving DST from the last Sunday of October to the first Sunday of November (delayed by one week).

Now you would have thought that the computer industry would have learned their lessons after Y2K, but they did not. To make matters worse, rather than keep DST rules in the host OS, we now also need to patch:

To add insult to injury, since those Y2K days many North American computer professionals have been let go and their jobs have been outsourced to India where people don't observe DST because they live so close to the equator. Oh well, just another mess linked to the effects of extreme capitalism.

UNIX and Linux

To the best of my knowledge, no RTC (real time clock) chips save the time zone. This means that just after a computer's local time has changed, a BIOS call must be made to save the new time to the RTC chip. Failure to do this means that a rebooted computer may come up with the wrong time. For the past 20 years most UNIX systems updated the RTC from root's crontab by calling /usr/sbin/rtc every morning in APRIL and OCTOBER.

caveat:
Linux systems usually employ the command: hwclock -w

You should to stick with database support

A good way to avoid future date-time problems is to stick with products with built-in support. For example, there are "date" and "datetime" objects built into most databases. Look at these two examples from MySQL and MariaDB. The second example is a hack to magically return the data in ISO-8601 "odometer" format

MariaDB [(none)]> select now();
+---------------------+
| now()               |
+---------------------+
| 2018-10-22 14:13:23 |
+---------------------+
1 row in set (0.00 sec)

MariaDB [(none)]> select now()+0;
+----------------+
| now()+0        |
+----------------+
| 20181022141330 |
+----------------+
1 row in set (0.00 sec)

MariaDB [(none)]>

Now try this experiment:
  1. create an experimental database called junkdb
  2. create a table in it called junk which is comprised of a column which has a type of DATE
  3. Now try to create a record with the value of 2022-02-29 which will throw a warning because 2022 is not a leap year
MariaDB [(none)]> CREATE DATABASE `junkdb`;
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> CREATE TABLE `junkdb`.`junk` ( `x1` INT NOT NULL AUTO_INCREMENT, `y2` DATE NOT NULL, `z3` VARCHAR(45) NOT NULL, PRIMARY KEY (`x1`));
Query OK, 0 rows affected (0.01 sec)

MariaDB [(none)]> use junkdb;
Database changed
MariaDB [junkdb]> insert into junk set y2="2022-03-01", z3="test 1";
Query OK, 1 row affected (0.00 sec)
MariaDB [junkdb]> insert into junk set y2="2022-02-29", z3="test 2"; Query OK, 1 row affected, 1 warning (0.00 sec) MariaDB [junkdb]> select * from junk; +----+------------+--------+ | x1 | y2 | z3 | +----+------------+--------+ | 1 | 2022-03-01 | test 1 | | 2 | 0000-00-00 | test 2 | +----+------------+--------+ 2 rows in set (0.00 sec) MariaDB [junkdb]>

Linux: ntpd, chronyd, timedatectl

Links

Calendars Date + Time Formatting
Back to Home
Neil Rieck
Waterloo, Ontario, Canada.