• Home
  • Trace mobile number (From India)
  • Entertainment
  • SiteMap
  • Home
  • ASP.NET
  • C#
  • BLOGGING
  • SQL SERVER
  • FACEBOOK
  • Entertainment
Showing posts with label Javascript date and time. Show all posts

This javascript code will display the current time from the client’s computer. This will display the format you might see on a typical digital clock -- HH:MM AM/PM (H = Hour, M = Minute).

<h4>The Current Time Is 
<script type="text/javascript">
<!--
var dateobj = new Date()
var hrs = dateobj.getHours()
var min = dateobj.getMinutes()
if (min < 10){
min = "0" + min
}
document.write(hrs + ":" + min + " ")
if(hrs > 11){
document.write("PM")
} else {
document.write("AM")
}
//-->
</script>
</h4>

Display:

The Current Time Is

As the title of post implies, in this tutorial i will show you how to get the date and time from the visitor's computer using an example.here you will get the the basic information about how to create a date object in javascript.

How To Create  a Date Object
When a date object is created, it is stored in what's called a variable.Below is the syntax to create a date object.
var date = new Date();
Example:The code given below will show the today date and time from client computer. 
<script language="javascript">
function myFunction(){
    var date = new Date();
    alert(date.toString());
 
}
</script>
<input type="button" onclick="myFunction();" value="Today's Date Is" />

Click on this button will display datetime from your computer.
How To Extract Information From that Date Object
Lots of information can be extracted from a date object. In this tutorial, we'll extract only some important info:
   
    var hour        = date.getHours();
    var minute      = date.getMinutes();
    var second      = date.getSeconds();
    var monthnumber = date.getMonth();
    var monthday    = date.getDate();
    var year        = date.getYear();
Older Posts Home

Most Read

  • How to Capitalize the First Letter of All Words in a string in C# ?
  • keyboard shortcuts For Windows
  • List Of Best Free WordPress Plugins : 2012
  • Read Write XML Data-Read Write XML File Using C#, VB.NET In Asp.Net
  • How to Shake Internet Explorer - Javascript Code
  • How to Choose a Nice Topic for your Blog .
  • Free Search Engine Submission List ,search engine optimization
  • Number validation in Textbox of ASP.NET Using Regular Expression validator
  • Javascript:Percentage Gain Javascript Calculator
  • .Net Interview Questions and Answers on OOPS | OOPS Frequently Asked Questions
Google
Custom Search Bloggers - Meet Millions of Bloggers

Join Us On FaceBook

  • Recent Posts
  • Comments

All Topics

  • ▼  2014 (10)
    • ▼  January (10)
      • ASP.NET Interview Question : difference between ge...
      • Dot Net Framework:What is the .NET Framework?
      • Dot NET Framework - .NET Framework Interview Quest...
      • What is the differences between MVC2,MVC3 and MVC4...
      • Is try catch is using a good coding (exception han...
      • What is the use of Just - In - Time (JIT)?
      • What is GUID , why we use it?,how to create a GUID
      • How to Rename database table column in sqlserver
      • How to Rename Database in sqlserver
      • Asp.net Example Calendar Control
  • ►  2013 (14)
    • ►  October (1)
    • ►  April (2)
    • ►  March (11)
  • ►  2012 (142)
    • ►  December (25)
    • ►  October (1)
    • ►  September (9)
    • ►  August (2)
    • ►  July (7)
    • ►  June (2)
    • ►  April (5)
    • ►  March (27)
    • ►  February (27)
    • ►  January (37)
  • ►  2011 (23)
    • ►  December (3)
    • ►  November (6)
    • ►  October (12)
    • ►  September (2)
  • ►  2009 (1)
    • ►  June (1)

Tips & Tricks

  • What is good One Blog and Many Categories, or Many Blogs with One Categories?
  • Adding Twitter tweet button to each Blogger posts.
  • How to Choose a Nice Topic for your Blog .
  • Embedding YouTube Videos ,movie in your blog
  • Facebook iFrame Apps – Getting Rid of Scrollbars
  • Facebook Analytics:How to Set Up Your Website or Blog with Facebook Insights for Domains
  • How To Add Perfect Share Box to Blogger
  • Blogger Free Images Hosting Tip,Free unlimited bandwidth image hosting for Blogger blogs
  • Add “Link to this post” codes below Each blogger posts
  • Free Search Engine Submission List ,search engine optimization
  • Adsense Tips for Maximum CTR
  • List Of Best Free WordPress Plugins : 2012
2012 tectopix. All rights reserved.
Designed by tectopix