Twofor
Decentralized Marketplace Creator
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
200 XP
In this chapter, You will learn to make a Date of birth counter into days, hours and time. Just follow the tutorial below and download the source code.
DIRECTIONS
Creating our HTML code
Creating our javascript code
You have now created a date counter that counts days, hours and minutes between the date today and the date you entered. For more suggestions and questions feel free to comment below or email me at [email protected]
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
DIRECTIONS
Creating our HTML code
- <FORM
name
=
"live"
>
- <BR
><BR
><BR
>
- <TABLE
border
=
1
>
- <tr
>
- <td
><INPUT
TYPE
=
"button"
NAME
=
"start"
VALUE
=
"Start"
ONCLICK
=
"lifetimer(this.form)"
></
td
>
- <td
><INPUT
TYPE
=
"reset"
NAME
=
"resetb"
VALUE
=
"Reset Age"
></
td
>
- </
tr
>
- <tr
>
- <td
>
Date of birth:</
td
>
- <td
><INPUT
TYPE
=
"text"
NAME
=
"age"
VALUE
=
""
SIZE
=
20
placeholder=
"January 10, 1994"
>
</
td
>
- </
tr
>
- <TR
><TD
>
You are days old:</
TD
>
- <TD
>
- <INPUT
TYPE
=
"text"
NAME
=
"time1"
VALUE
=
""
size
=
8
>
- </
TD
>
- </
TR
>
- <TR
><TD
>
Plus hours old:</
TD
>
- <TD
>
- <INPUT
TYPE
=
"text"
NAME
=
"time2"
VALUE
=
""
size
=
8
>
- </
TD
>
- </
TR
>
- <TR
><TD
>
Plus minutes old:</
TD
>
- <TD
><INPUT
TYPE
=
"text"
NAME
=
"time3"
VALUE
=
""
size
=
8
></
TD
>
- </
TR
>
- </
TABLE
>
- </
FORM
>
Creating our javascript code
- <
SCRIPT LANGUAGE=
"JAVASCRIPT"
>
- <!--
hide this
script tag's contents from old browsers
- function lifetimer(){
- today = new Date()
- BirthDay = new Date(document.live.age.value)
- timeold = (today.getTime() - BirthDay.getTime());
- sectimeold = timeold / 1000;
- secondsold = Math.floor(sectimeold);
- msPerDay = 24 * 60 * 60 * 1000 ;
- timeold = (today.getTime() - BirthDay.getTime());
- e_daysold = timeold / msPerDay;
- daysold = Math.floor(e_daysold);
- e_hrsold = (e_daysold - daysold)*24;
- hrsold = Math.floor(e_hrsold);
- minsold = Math.floor((e_hrsold - hrsold)*60);
- document.live.time1.value = daysold
- document.live.time2.value = hrsold
- document.live.time3.value = minsold
- window.status = "Well at the moment you are " + secondsold + "............ seconds old.";
- timerID = setTimeout("lifetimer()",1000)
- }
- // -- done hiding from old browsers -->
- </script>
You have now created a date counter that counts days, hours and minutes between the date today and the date you entered. For more suggestions and questions feel free to comment below or email me at [email protected]
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.