Home     |      Learn AJAX     |      Forum     |      Register     |      Submit Resource     |      Submit Article      |      Contact Us

Home AJAX-Tips
 

Date and Time Extraction Techniques

 

Adding date and time functionality in your Ajax based application is a simple but very useful function. By adding the date and time option in the application, developers can provide additional information to users. Some can even use the data offered by the date and time function for additional functions.



Implementing time and date in an Ajax or JavaScript based application is relatively simple since it connects online in order to provide the needed information. Developers are not required to provide a source of the time and date. The code should be enough for the time and date to be loaded in the application.


The application doesn't even have to be limited in a single format. Developers can implement various formats in their application for their intended use.


The basic function for the time and date in an Ajax based application goes this way:


new Date();
alert(now);


This form of time and date is often attached to a function. That means the data and time can be revealed if the user clicks on a specific command in the application. From this basic function, developers should be able to add few functions if they want to customize the data displayed in the application.


Adding a UTC Format


The previously indicated date and time format do not specify which timezone or source of information. If the exact source will not be included, the timezone will depend on which browser the developer uses.


However, an accurate data format can be implemented in an Ajax or JavaScript based application by using the UTC or the Coordinated Universal Time. It's not a requirement to indicate the source but a simple code should display UTC immediately.


The code goes this way:


alert(now.toUTCString());


The default string format will indicate the day of the week, date and time.


But the standard format can be further customized. Additional commands can be added so that the date and be arranged according to the developers specifications.


The following format can indicate the specific order of date and time:


date.UTC(now.getMonth(), now.getHours())


Using ISO Data Format


This format can be easily recognized by JavaScript. It's a very simple format that displays the date and time in numbers. The code for this format goes this way:


new Date() toISOString();


Unfortunately, this type of command is currently accepted only in Firefox 3.5 and it's later versions.


Combining the Date Functions with other Online Commands


As already indicated, the date and time functions are not just used for display purposes in the application. Developers can also use the information extracted for other commands in the application especially if the developers are looking for additional data.



Integrating the date and time function is relatively easy. The date and time function will come out as an object which can become a target for other functions in the application. As long the date and time coding format can be read by the browser, interacting date and time function with other commands in the application will not yield any problem in implementing the application.



Read Next: Loading CSS Gradients in Canvas



 

 

Comments



Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links