473,395 Members | 1,411 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

current date in javascript

pls any one help me

I want current date in dd/mm/yyyy format in javascript
Jul 24 '09 #1
2 3056
acoder
16,027 Expert Mod 8TB
You can get the current date with:
Expand|Select|Wrap|Line Numbers
  1. var today = new Date();
Then use the get*** methods to get the day, month and year. Note that getMonth() is 0-based, i.e. 0=January, and use getFullYear() for the year, not getYear().
Jul 24 '09 #2
rnd me
427 Expert 256MB
Expand|Select|Wrap|Line Numbers
  1.  
  2. Date.prototype.toShort = function () {
  3.     function f(n) {
  4.         return n < 10 ? "0" + n : n;
  5.     }
  6.     return f(this.getDate() ) + "/" + f(this.getMonth() + 1) + "/" +  this.getFullYear()   ;
  7. };
  8.  
  9. alert((new Date).toShort());//==="25/07/2009"
  10.  
  11.  
Jul 25 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: John Norvell | last post by:
I just noticed that recently the javascript I was using to format and display the last modified date of my web page is always reporting the current date instead. It used to work fine. This is true...
3
by: Kevin Gibbons | last post by:
Hello all, I've browsed through past usenet archives, but can't seem to come across quite the javascript I'm looking for. I'm looking for a simple javascript that will display the date as such:...
13
by: Luigi | last post by:
Imagine I have a small, static, personal site (I do, actually: http://kirpi.it/). And imagine that, just below the title of the page, I would like to have a comment, or a news line, or a birthday...
5
by: Pontifex | last post by:
Hi all, 1. I have a large set of web pages and at the top of each page I have a script that prints out the current date. It's always in the body. Is there a way to put that script in a .js...
2
cassbiz
by: cassbiz | last post by:
I am using strtotime and I have read up on some examples and am getting the wrong output, it jumps by several days instead of one day at a time. Ultimately what I am trying to accomplish is to set...
3
by: remya1000 | last post by:
i'm using ASP with MSAccess as database. i have two buttons and two textbox in my page. when i press my first button (First month) i need to display the current month in one textbox and last one...
1
by: simbarashe | last post by:
Hie could someone please help me with getting and using the current page url. I have a function that gets the url, I want to use it with header(location : XXX) but it wont work. The code is as...
2
by: aloke.sarnobat | last post by:
Hello, I am new to this forum, so your help would be most appreciated. I am trying to create a javascript where, on clicking a button, I will be able to download the latest log file. But the...
4
xstatic
by: xstatic | last post by:
After searching through the hundreds of links about "Javascript Date Formatting", all I am finding is how to format dates that gives a "current date" result. Here is what I need... I have a...
23
by: dhtmlkitchen | last post by:
JSON We all know what it is. In ECMAScript 4, there's a JSON proposal: Object.prototype.toJSONString String.prototype.parseJSON The current proposal, String.prototype.parseJSON, returns...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.