473,381 Members | 1,555 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,381 software developers and data experts.

sysdate function

Max
I need a little javascript function that returns the date of today in the
format dd/mm/yyyy
example:
September 2, 2003 ==> 02/09/2003

For control reasons, it cannot be 2/9/2003 or 02/9/2003 or 2/09/2003 but
only 02/09/2003

December 14, 2003 ==> 14/12/2003

Thanks
Jul 20 '05 #1
5 18715
Lee
Max said:

I need a little javascript function that returns the date of today in the
format dd/mm/yyyy
example:
September 2, 2003 ==> 02/09/2003

For control reasons, it cannot be 2/9/2003 or 02/9/2003 or 2/09/2003 but
only 02/09/2003

December 14, 2003 ==> 14/12/2003


Per the FAQ for this newsgroup, you should look here:
http://www.merlyn.demon.co.uk/js-dates.htm

You might also consider using the format 2003-12-14, if possible.

Jul 20 '05 #2
Max
doesn't help much
"Lee" <RE**************@cox.net> a écrit dans le message news:
bj********@drn.newsguy.com...
Max said:

I need a little javascript function that returns the date of today in the
format dd/mm/yyyy
example:
September 2, 2003 ==> 02/09/2003

For control reasons, it cannot be 2/9/2003 or 02/9/2003 or 2/09/2003 but
only 02/09/2003

December 14, 2003 ==> 14/12/2003


Per the FAQ for this newsgroup, you should look here:
http://www.merlyn.demon.co.uk/js-dates.htm

You might also consider using the format 2003-12-14, if possible.

Jul 20 '05 #3
"Max" <ce******@cgey.com> wrote in
news:bj**********@s1.read.news.oleane.net:
doesn't help much
"Lee" <RE**************@cox.net> a écrit dans le message news:
bj********@drn.newsguy.com...
Max said:
>
>I need a little javascript function that returns the date of today
>in the format dd/mm/yyyy
>example:
>September 2, 2003 ==> 02/09/2003

<html>
<head></head>
<body>
<script>
function formatDate(date,frm)
{
var str = new String(frm);
var m = date.getMonth();
var d = date.getDate();
var y = date.getFullYear();
var w = date.getDay();
var s = new Array();
s["d"] = d;
s["dd"] = (d < 10) ? ("0" + d) : d;
s["M"] = 1+m;
s["MM"] = (m < 9) ? ("0" + (1+m)) : (1+m);
s["y"] = y;
s["yy"] = new String(y).substr(2, 2);
s["yyyy"] = y;
var re = /(.*)(\W|^)(d|dd|ddd|dddd|M|MM|MMM|MMMM|y|yy|yyyy)( \W|$)(.
*)/;
while (re.exec(str) != null) {
str = RegExp.$1 + RegExp.$2 + s[RegExp.$3] + RegExp.$4 +
RegExp.$5;
}
return str;
}

document.write(formatDate(new Date(),'dd/MM/yyyy'));

</script>
</body>
</html>

--
In theory there is no difference between theory and practice. In practice
there is. - YB
Jul 20 '05 #4
JRS: In article <Xn*********************@198.80.55.250>, seen in
news:comp.lang.javascript, Sean Jorden <s_***********@no.spam.n_o_r_a.d.a.com>
posted at Wed, 3 Sep 2003 07:49:46 :-
"Max" <ce******@cgey.com> wrote in
news:bj**********@s1.read.news.oleane.net:
doesn't help much
"Lee" <RE**************@cox.net> a écrit dans le message news:
bj********@drn.newsguy.com...
Max said:
>
>I need a little javascript function that returns the date of today
>in the format dd/mm/yyyy
>example:
>September 2, 2003 ==> 02/09/2003

<html>
... ... ... ...
</html>


But he specifically requested a little function.

function LZ(x) {return(x<0||x>9?"":"0")+x}

function formatDate(date) {
with (date) return LZ(getDate())+'/'+LZ(getMonth()+1)+'/'+getFullYear()
}

document.write(formatDate(new Date()))

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
Jul 20 '05 #5
Dr John Stockton <sp**@merlyn.demon.co.uk> wrote in
news:ca**************@merlyn.demon.co.uk:


But he specifically requested a little function.


sorry, I don't like non-reusable code.
Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: WroteForLuck | last post by:
I am trying to write a simple SQL statement which will take a string (startdate) in the format DDMMYYYY and compare it to a date stored in an Oracle database. My SQL is as follows: <% "select...
1
by: Yaroslav K. Kravchishin | last post by:
Oracle 7.0.1 Server When I type SQL> select sysdate from dual; SYSDATE --------- 01-OCT-03 01-OCT-03 2 rows selected.
0
by: Yaroslav K. Kravchishin | last post by:
Oracle 7.0.1 Server When I type SQL> select sysdate from dual; SYSDATE --------- 01-OCT-03 01-OCT-03 2 rows selected.
3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
4
by: sajan | last post by:
Hi, I new to python. I'm trying to make changes to an existing python code . The code has an if condition something like if datetime(*(time.strptime(creation_date, '%d-%b-%y'))) <...
5
rsrinivasan
by: rsrinivasan | last post by:
Hi, When i Execute this query, I got the result as 29-MAY-07 select sysdate from dual; But i want 29-MAY-2007. What is the query for it? Thanks,
1
by: sajithamol | last post by:
What is the difference between current_date & sysdate function?
3
by: premkumarsp1 | last post by:
hi in the oracle sysdate, time is coming wrongly. THe date and time in the OS from where i am accessing oracle and in the OS where oracle is installed is correct. I want to know how to update time...
1
by: karuppiah | last post by:
Hi All, i need query,how to select last 3 month ,last 3wek,last 3 days , this last 3 month and 3 week should be friday, using sysdate from dual table, there is no exsting table, pls any one help...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.