Time is never interrupted. In the context of programming, it has a beginning, content, and end. As soon as the work begins, the program is launched, the script is turned on, the site has opened ... At first, time in programming became “data”, that is, “nothing”, but many years later it regained its legal status.
Computer business began with a timer (any processor runs on a timer): without clear time signals, neither digital, nor analog, nor natural - simply does not exist. Time is always present in everything, but the quality of the program and, what is very important at times, how long it will exist depends on how it is presented and taken into account.
Essential Philosophy of Time
At different periods, different languages perceived the time factor differently and had a specific date format. But if you do not take the real-time systems of the past, then understanding in the proper sense (in mass, first of all) has come quite recently.
At first, reality was poorly reflected in programming. The developers sought to complete the task, but did not always realize how much time matters.
Surprisingly, no one even had a thought: many developers and users of programs did not even think at the end of the last century that the problem of the number of digits in the year designation in date format would be disastrous.
Only when the year 2000 approached did everyone suddenly think that the formal framework is tight, and not just for what the programmer invented for himself, developing his own algorithm.
When the passions subsided by the number of digits in the year, a new idea arose: localization. It turned out that the date is very dependent on the place of its application, and the concept of date format finally moved from simple representations to the category of structured data.
Space problems and mathematical calculations
The undoubted success of Fortran, the language to which the initial bias towards large computations is attributed, brought to life only one consequence. The computer was not fast enough to lay out the curves along the trapezoids, calculating the differentials and integrals. Not everyone understands the deep meaning of higher mathematics, but everyone notices the time that the computer spends on processing a different formula.
Processing time data in large volumes or over long distances acquires a significant time factor: the error may well be equal to the cost of a spacecraft flying off in the wrong direction, just because at a certain point in time one or another engine did not turn on.
JavaScript date format (browser language)
Perhaps the Internet has become a cause of growing interest in time as a continuous and significant given, this is not so important. All modern programming languages have an object or structure equipped with an appropriate structure and their own semantics as a temporary element.
In particular, in JavaScript, the date format looks like a Date object:
Here, the padl () function simply complements a number to two digits. It’s clear from the text what a date is in JavaScript - everything is very simple, neatly and conveniently marked.
Java Date Format (Sun Concept)
A different attitude to date in the Java language. Date format is represented here by more than one abstract class. However, the abundance of his methods deserves a separate article. Formatting is moved to a separate object, which allows you to consider the locale when performing date format operations, that is, display the date in the language in which it is necessary.
The developer can use the classes: DateFormatSymbols, Calendar, GregorianCalendar, TimeZone, MaskFormatter and others. The idea of date format is much more extensive than in other languages. Each class has its own purpose.
It doesn't matter whose merit is in the globalization of date format. Sun’s financial capabilities and high technology, leading to a serious approach to the concept of time, or global information ideas and powerful Oracle databases. But the Java language has turned the simple concept of date format into a system of diverse objects and globalized its implementation.
JQuery calendar
An excellent, simple, and affordable date implementation is undoubtedly the datapicker. Using the jQuery mechanism, it has become surprisingly easy to use, it allows you to quickly insert the ability to select the exact time or time interval on any page and present the result in string format date.
The input tag, receiving the input focus, displays using the $ ( '#dateField' ) .datepicker () method a calendar with which you can change not only the appearance according to the subject of the page, but also localize it to the desired language. You can set not only the date, but also the time and days of the week.
Initially, a datapicker appeared for the input field, but can be used on another element - div or span, for example. The result can be not only placed in the input field as a formatted string (you can easily change the contents of the timeline), but also used as a variable.
Datapicker is, of course, not a date format view from Oracle / Java, but the capabilities of this widget will satisfy the most sophisticated tastes. The developer does not need to write his own version of the presentation of the date and the algorithms for working with him - he receives not only a convenient calendar, but also a dialogue (a set of functionalities for moving by day, week, month.
You can record the start date of the period and the end date.
Even if the site requires its own version of the presentation of time, at the initial stage of development it is quite reasonable to use datepicker.