Fun with the javascript date object.

Posted on July 10, 2008 in Technology

So for a few projects recently I needed to make use of Javascript Date functionality. At first glance it seems like this archaic system of creating and managing dates but after some tinkering I am realizing yet again that tools created in the computer dawn of time are unbelievably robust.

One of the issues I keep running into is when taking a date which you are working with and trying to make a copy of a date object, when you modify the date of the clone the original is affected. That’s because it’s a reference and not a clone. Watch out for this as I was bit a few times.

var date1 = new Date(“07/05/08”) var myDate = date1; //this creates a reference to the original myDate.setDate(“15”); date1.getDate(); //equals 15

Some other cool things that you can do with the date object is that you can very easily add days to a date, and it will calculate if months change, leap years etc.

myDate.setDate(myDate.getDate() + 10) // adds 10 days.

You can also subtract two dates from each other.

christmas = new Date(“12/25/08”); today – new Date(); secondsToChristmas = christmas – today; //time to christmas in milliseconds daysToChristmas = secondsToChristmas /(1000*60*60*24); //yey math is fun!

[ There are no comments yet, be the first to add a comment ]

Rusty

Posted on March 25, 2008 in Sports
Update: They turned it around in classic Sox fashion, the boys are back in town. woot.

It's a little after 6:30 in the AM. I am not sure WHY exactly but I find myself on my couch watching the Red Sox 2007 home opener.

The Red Sox look super rusty -- that could be due to the fact that they are not even done with spring training yet! I can't tell you the reasoning for having the Red Sox play two official games in Japan before returning back to the US and playing 3 more spring training games but none the less they (especially Matsuzaka) look completely uninspired.

I think they Yankees had a similar schedule a few years back when they did their tour of Japan and that caused them to get off to a very slow start -- hopefully this does not repeat itself.

It's only the bottom of the 2nd inning (bases loaded) so hopefully they will turn things around.

[ There are no comments yet, be the first to add a comment ]

Nutty

Posted on March 14, 2008 in Articles , Internet , Life , Technology

So Its been a whirlwind of a week. SXSW was a great experience and know then next time down there how better to prepare myself. SXSW is not about the conference –it's totally about the people and connecting.

If you are interested in a few good Pod-casts (when they come online) look for the following...

  • Derek Featherstone’s “All I know about accessibility I learned from star wars”
  • "Browser Wars"
  • "Javascript Framework Secrets"

Thanks to everyone out there that made it special .. you know who you are.

Last night I also went to the Markup and Style Society's meet-up in Boston .. it was awesome. Dan and Ethan put together some panels and also some giveaways. Also free Beer and Pizza -- you cant beat that!

The guys from Filament group offered up their space but more importantly their knowledge. Scott gave a great presentation about Progressive Enhancement.

Check out some of their great development lab at http://www.filamentgroup.com/lab

[ There are no comments yet, be the first to add a comment ]

About your Author

This site is owned and operated by Eric Webster. A designer/developer in the Boston area and these are the rantings and ravings of daily life.

For more information visit the About section

Previously

Twitter Updates

    My Del.icio.us Links