Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title>Until Vacation TIME!!!</title>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" crossorigin="anonymous">
- <!--https://github.com/datejs/Datejs-->
- <script src="https://cdnjs.cloudflare.com/ajax/libs/datejs/1.0/date.min.js"></script>
- <script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" crossorigin="anonymous"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" crossorigin="anonymous"></script>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" crossorigin="anonymous"></script>
- <script>
- var today = new Date().toString('M/d/yyyy');
- var day = "11/16/2017";
- $(document).ready(function(){
- //get time between dates;
- var b = dateDiff(today,day,"d");
- $("#main").html("There are " + b + " days until " + day);
- });
- function toDate(s) {
- var s = s.split('/');
- return new Date(s[2], --s[0], s[1]);
- }
- function dateDiff(from,to,format) {
- var milliseconds = toDate(to) - toDate(from);
- var days = milliseconds / 86400000;
- var hours = milliseconds / 3600000;
- var weeks = milliseconds / 604800000;
- var months = milliseconds / 2628000000;
- var years = milliseconds / 31557600000;
- if (format == "h") {
- return Math.round(hours);
- }
- if (format == "d") {
- return Math.round(days);
- }
- if (format == "w") {
- return Math.round(weeks);
- }
- if (format == "m") {
- return Math.round(months);
- }
- if (format == "y") {
- return Math.round(years);
- }
- }
- </script>
- </head>
- <body>
- <div id="main" class="container">
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement