Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 04-04-2006, 03:50 PM Format date
Average Talker

Posts: 19
Trades: 0
Hello all. I have a date selector, in which upon selecting the date (i.e. Jan 3, 2006), it puts it like 01/03/2006. What I am wondering is if it is possible to change it to format it like 1/3/2006? If yes, how would I do it, and what should I look for in the code so I know where to change it?

Thanks in advance,

Parallon
parallon is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-04-2006, 05:56 PM Re: Format date
Experienced Talker

Posts: 46
Location: Denmark
Trades: 0
What kind of script is it? PHP/ASP? Or anything else?
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
Sarangan is offline
Reply With Quote
View Public Profile Visit Sarangan's homepage!
 
Old 04-04-2006, 06:36 PM Re: Format date
Junior Talker

Posts: 1
Trades: 0
Try this:
Code:
<html><head><title>Date</title><script type="text/Javascript">
function showdate() {
d=new Date() //Gets all the date information
myyear=d.getFullYear() //Gets the year in 4 digits, like 2006
mydate=d.getDate() //Gets the number the day is of the month
mo=d.getMonth() //Gets the month number, beginning at 0
mymonth=mo+1 //Because you don't want 1/2/2006, you want 1/3/2006
document.getElementById('datespan').innerHTML=mymonth+"/"+mydate+"/"+myyear //Changes the element with datespan for an id's innerHTML, or text inbetween the tags
//You can also try using .value for something like an <input> tag
}
</script></head><body onload="showdate()"><span id="datespan">&nbsp;</span></body></html>
If you would like to learn how to write Javascript, I highly recommend W3Schools.com. That's where I learned Javascript, and it really helped me. You can also try this and this for the Date and Time on Javascript.
sharkbaitbobby is offline
Reply With Quote
View Public Profile
 
Old 04-04-2006, 09:28 PM Re: Format date
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Just posted some code for this at Snippet Collection as formatDate()
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-27-2006, 11:45 AM Re: Format date
Average Talker

Posts: 19
Trades: 0
Thank you very much for your help.

Parallon
parallon is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Format date
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.61523 seconds with 12 queries