The javascript below grabs the user's date (client date) from their computer and returns the value.
I want to turn this javascript (and a time javascript) into a user defined function. I spent a lot of time on this and couldn't figure it out.
<!--- Start Script --->
<script>
function briefclientdate(){
var currentdate = new Date()
var numday = currentdate.getDate()
var nummonth = currentdate.getMonth()
var numyear = currentdate.getYear()
var monthname = "01"
// Start changing the month number to an actual labeled month name.
if (nummonth == 1) {
var monthname = "02"
}
if (nummonth == 2) {
var monthname = "03"
}
if (nummonth == 3) {
var monthname = "04"
}
if (nummonth == 4) {
var monthname = "05"
}
if (nummonth == 5) {
var monthname = "06"
}
if (nummonth == 6) {
var monthname = "07"
}
if (nummonth == 7) {
var monthname = "08"
}
if (nummonth == 8) {
var monthname = "09"
}
if (nummonth == 9) {
var monthname = "10"
}
if (nummonth == 10) {
var monthname = "11"
}
if (nummonth == 11) {
var monthname = "12"
}
else {
// Do nothing...
}
document.write("" +monthname+ "/" +numday+ "/" +numyear)
}
briefclientdate()
</script>
I want to turn this javascript (and a time javascript) into a user defined function. I spent a lot of time on this and couldn't figure it out.
<!--- Start Script --->
<script>
function briefclientdate(){
var currentdate = new Date()
var numday = currentdate.getDate()
var nummonth = currentdate.getMonth()
var numyear = currentdate.getYear()
var monthname = "01"
// Start changing the month number to an actual labeled month name.
if (nummonth == 1) {
var monthname = "02"
}
if (nummonth == 2) {
var monthname = "03"
}
if (nummonth == 3) {
var monthname = "04"
}
if (nummonth == 4) {
var monthname = "05"
}
if (nummonth == 5) {
var monthname = "06"
}
if (nummonth == 6) {
var monthname = "07"
}
if (nummonth == 7) {
var monthname = "08"
}
if (nummonth == 8) {
var monthname = "09"
}
if (nummonth == 9) {
var monthname = "10"
}
if (nummonth == 10) {
var monthname = "11"
}
if (nummonth == 11) {
var monthname = "12"
}
else {
// Do nothing...
}
document.write("" +monthname+ "/" +numday+ "/" +numyear)
}
briefclientdate()
</script>