HTML, JavaScript And CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingHTML, JavaScript And CSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old April 16th, 2004, 04:47 AM
stevie17 stevie17 is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 59 stevie17 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Pop-up Calendar Date format

I have some script (below) which is returning the date from a pop-up calendar. My problem is that the date is being returned in a dd/mm/yyyy format. However I need to be come back with a dd/mm/yy format. Is there anything simple I can do with the code to achieve this.

function y2k(number) { return (number < 1000) ? number + 1900 : number; }

var today = new Date();
var day = today.getDate();
var month = today.getMonth();
var year = y2k(today.getYear());

function padout(number) { return (number < 10) ? '0' + number : number; }

function restart() {
document.accounting.date.value = '' + padout(day) +'/' + padout(month - 0 + 1) + '/' + year;
mywindow.close();

Reply With Quote
  #2  
Old May 6th, 2004, 09:14 PM
Hawknz's Avatar
Hawknz Hawknz is offline
Blonde Contributor
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: New Zealand
Posts: 98 Hawknz User rank is Sergeant (500 - 2000 Reputation Level)Hawknz User rank is Sergeant (500 - 2000 Reputation Level)Hawknz User rank is Sergeant (500 - 2000 Reputation Level)Hawknz User rank is Sergeant (500 - 2000 Reputation Level)Hawknz User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 21 h 59 m 57 sec
Reputation Power: 13
Smile Pop-up Calendar Date format

Replace the following line:

var year = year.substring(year.length-2); // pull out right 2 which gives you yy

While the above will work, I prefer the following as JS doesn't have a right() function.

Example:
Quote:
var str = "2004";
alert(Right(str, 2));


Code:
 
<script language="JavaScript">
function Right(str, num) { return str.substring(str.length-num);  // pull out right num }
</script>
__________________
Hawk - The flightless Kiwi bird

Did I help you out? Click the and agree.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingHTML, JavaScript And CSS Help > Pop-up Calendar Date format


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway