|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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(); |
|
#2
|
||||
|
||||
|
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:
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.
|
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > Pop-up Calendar Date format |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|