William Jiang

JavaScript,PHP,Node,Perl,LAMP Web Developer – http://williamjxj.com; https://github.com/williamjxj?tab=repositories

A good example to get Javascript Date

A good example to get Javascript Date

The following is a good example to get Javascript Date:

<script type="text/javascript">
var d=new Date();
var monthname=new Array("January","February",
 "March","April","May","June","July","August",
 "September","October","November","December");
//Ensure correct for language. English is "January 1, 2004"
var TODAY = monthname[d.getMonth()] 
    + " " + d.getDate() + ", " 
    + d.getFullYear();
</script>

After this, use the following to present date on the screen:

  • $(input).val(TODAY);
  • $(div).text(TODAY);
  • $(span).html(TODAY).fadeIn();
  • $(TODAY).appendTo($(id));
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: