Working with DateTime - Day 2 - Part 2

Sign in to queue

Description

When working with Silverlight applications for the Windows Phone 7, you'll often need to work with a date and/or time. This video demonstrates how to work with the DateTime class and TimeSpan class to add dates, calculate differences in time, retrieve parts of a DateTime object, format for display, and more.

Download the source code in c#

Download the source code in VB.Net

Embed

Download

Download this episode

The Discussion

  • User profile image
    John Marshall

    So is your birthday Dec 7th or July 12th?
    Rembmer, this is an international audience and your code would fail if the day of the month was greater than 12.

  • User profile image
    BobTabor

    @John ... Yikes ... good point.  I can't remember everything I did in this video (and I hate watching myself!!!) but depending on how I went about this, I would hope that my phone's location settings would iron this out magically for me.  I may need to revisit this if I get a lot of negative feedback on it.  Sorry about that!

  • User profile image
    EDE

    HEY is something wrong with the WMV HQ FILE?!  :|

  • User profile image
    EDE

    sorry i had encountered a bug with my media player. :D

  • User profile image
    Mintydog

    Some great methods there to use. I'm surprised by the vast amount of methods on offer and what they do, I can have fun with the date and time one but hoping it is intelligent enough to recognise if im using a date first rather than a month.

    Cheers Bob.

  • User profile image
    nomadoj

    @BobTabor. Loving the tutorial, thanks for the clear, descriptive videos.On the point about whether the phone's regional settings would sort out DateTime.Parse if it was entered dd/mm/yyyy instead of mm/dd/yyyy - you are right that the phone will do this. If anyone wants to try it you can do this in the Settings screen under Region and Language in the emulator. If you scroll down there is a System Locale setting. Just remember to hit the 'Tap here to save your changes' if you do change the option (for example I used United Kingdom). The emulator will restart, and save your settings - so just go back and revert if you want to change back.

  • User profile image
    optimus

    thanks Bob

  • User profile image
    MacheteFrom​Germany

    Hi Guys!

    I'm wondering why my IDE not adds () to methods, if i choose them from auto completion.

    For example:

    I type myDateValue.

    now i choose ToString from the auto-completion and it just adds "ToString" but not "ToString()" how I expected.

    Its not really a big Problem but u know, developers are lazy ^^

    Is there an option in VS to change that behavior?

     

    Regards & Thanks

     

Add Your 2 Cents