Time and Weather
by Laurie
HTML
<script src="http://momentjs.com/downloads/moment.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.simpleWeather/3.0.2/jquery.simpleWeather.min.js"></script>
<script src="http://momentjs.com/downloads/moment-timezone-with-data-2010-2020.min.js"></script>
<div class="weatherContainer">
<div id="weather" class="weather"></div>
<div id="weather2" class="weather"></div>
<div id="weather3" class="weather"></div>
<div id="weather4" class="weather"></div>
<!-- END weatherContainer DIV -->
<div class="clearFix"></div>
<!-- END clearFloats -->
</div>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<div id="divLocal"></div>
CSS
html {
font-family: sans-serif;
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
body {
margin: 0;
}
article, aside, details, figcaption, figure, footer, header, hgroup, main, nav, section, summary {
display: block;
}
audio, canvas, progress, video {
display: inline-block;
vertical-align: baseline;
}
audio:not([controls]) {
display:none;
height:0
}
[hidden], template {
display: none;
}
a {
background: transparent;
}
a:active, a:hover {
outline: 0;
}
abbr[title] {
border-bottom: 1px dotted;
}
b, strong {
font-weight: bold;
}
dfn {
font-style: italic;
}
h1 {
font-size: 2em;
margin: 0.67em 0;
}
mark {
background: #ff0;
color: #000;
}
small {
font-size: 80%;
}
sub, sup {
font-size: 75%;
line-height: 0;
position: relative;
vertical-align: baseline;
}
sup {
top: -0.5em;
}
sub {
bottom: -0.25em;
}
img {
border: 0;
}
svg:not(:root) {
overflow:hidden
}
figure {
margin: 1em 40px;
}
hr {
-moz-box-sizing: content-box;
box-sizing: content-box;
height: 0;
}
pre {
overflow: auto;
}
code, kbd, pre, samp {
font-family: monospace, monospace;
font-size: 1em;
}
button, input, optgroup, select, textarea {
color: inherit;
font: inherit;
margin: 0;
}
button {
overflow: visible;
}
button, select {
text-transform: none;
}
button, html input[type="button"], input[type="reset"], input[type="submit"] {
-webkit-appearance: button;
cursor: pointer;
}
button[disabled], html input[disabled] {
cursor: default;
}
button::-moz-focus-inner, input::-moz-focus-inner {
border: 0;
padding: 0;
}
input {
line-height: normal;
}
input[type="checkbox"], input[type="radio"] {
-moz-box-sizing: border-box;
box-sizing: border-box;
padding: 0;
}
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button {
height: auto;
}
input[type="search"] {
...
JavaScript
$(document).ready(function () {
$(function () {
setInterval(function () {
var divLocal = $('#divLocal');
var utc = moment.utc().format('YYYY-MM-DD HH:mm:ss');
var localTime = moment.utc(utc).toDate();
localTime = moment(localTime).tz("America/New_York").format('ddd MMM D YYYY, h:mm:ss a z');
divLocal.text(localTime);
return localTime;
}, 1000);
});
var getLocalTime = setInterval(function () {
});
//var utc = moment.utc().format('YYYY-MM-DD HH:mm:ss');
//var localTime = moment.utc(utc).toDate();
//var ny = moment(localTime).tz("America/New_York").format('ddd MMM D YYYY, h:mm:ss a z');
var ny = moment().tz("America/New_York").format('ddd MMM D YYYY, h:mm a z');
var chicago = moment().tz("America/Chicago").format('ddd MMM D YYYY, h:mm a z');
var pasadena = moment().tz("America/Los_Angeles").format('ddd MMM D YYYY, h:mm a z');
var tokyo = moment().tz("Asia/Tokyo").format('ddd MMM D YYYY, h:mm a z');
$.simpleWeather({
zipcode: '',
woeid: '2459115',
location: '',
unit: 'f',
success: function (weather) {
html = '<p>' + weather.city + ', ' + weather.region + '</p>';
html += '<p>' + ny + '</p>';
//html += '<p>'+weather.updated+'</p>';
html += '<p><i class="icon-' + weather.code + '"></i> ' + weather.temp + '°' + weather.units.temp + '<p>';
html += '<p>' + weather.currently + '<p>';
$("#weather").html(html);
},
error: function (error) {
$("#weather").html('<p>' + error + '</p>');
}
});
$.simpleWeather({
zipcode: '',
woeid: '',
location: 'Chicago, IL',
unit: 'f',
success: function (weather) {
html = '<p>' + weather.city + ', ' + weather.region + '</p>';
html += '<p>' + chicago + '</p>';
...