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

Posts: 19
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
 
When You Register, These Ads Go Away!
     
Old 04-04-2006, 04:56 PM Re: Format date
Experienced Talker

Posts: 46
Location: Denmark
What kind of script is it? PHP/ASP? Or anything else?
__________________
Meta Search Engine - Tamil Wire - Tamil Chat - Nyheder
Sarangan is offline
Reply With Quote
View Public Profile Visit Sarangan's homepage!
 
Old 04-04-2006, 05:36 PM Re: Format date
Junior Talker

Posts: 1
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, 08:28 PM Re: Format date
chrishirst's Avatar
Super Moderator

Posts: 11,866
Location: Blackpool. UK
Just posted some code for this at Snippet Collection as formatDate()
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-27-2006, 10:45 AM Re: Format date
Average Talker

Posts: 19
Thank you very much for your help.

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

Thread Tools

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

vB 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.12843 seconds with 13 queries