Welcome to 2009 - where we've got a LOT of great stuff lined up for you. First of all, our "Monsters of Tech" class in Denver this coming April is still open for registration, and we've lowered the per-student price to just $2,000 for the entire week. Check out the Read the full story »
Features

These ongoing series of articles bring you new content on a weekly, biweekly, or monthly basis. Check back often!

Jack of All Tech

The minimum you need to know about the varied technologies that you support - even though they’re not really your thing.

Just for Fun

A little off-topic, but still eminently interesting: Gadgets, hobbies, contests, giveaways, and whatever pops into our minds.

Musings

Our take on what’s happening in the IT world - and most importantly how we think it’ll affect you. What do YOU think?

Windows Admin

Managing (and automating) Windows servers and desktops, including scripting and Windows PowerShell

Home » Features, Windows PowerShell

PowerShell: Dates and Times

There’s often times when you’ll need to work with dates. Perhaps you’re archiving information and need to establish a cutoff date, or perhaps you’re examining dates from AD and need to calculate how many days it’s been since a certain date. PowerShell generally makes it pretty easy to do.

Need to get a date?

$date = Get-Date

That also gets the current time. Try:

$date | gm

To see what all you can do with that date once you’ve got it. Need a short-formatted date?

$date.toshortdatestring()

Need to see what date it was a year ago?

$date.addyears(-1)

It’s really easy to work with dates using their built-in methods!

Oh, and see the TechNet Script Center for more details on date formatting, if you’re interested.

Technorati Tags: , ,

Related Posts

Rate this Post

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...