System.DateTimie

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?QUEyZTcyRQ==?=

    System.DateTimie

    I am struggling a little with these 2 problems:

    1. How can I convert an integer, representing x days from 01/01/0001 (the
    minimum value for DateTime, in dd/MM/yyyy) to dd/MM/yyyy?
    2. Is there any functionality for converting a date from one locale to
    another?

    Thanks for your help.
  • Alberto Poblacion

    #2
    Re: System.DateTimi e

    "AA2e72E" <AA2e72E@discus sions.microsoft .comwrote in message
    news:6C0C8233-736B-4C21-A87F-5DC96E6506A3@mi crosoft.com...
    1. How can I convert an integer, representing x days from 01/01/0001 (the
    minimum value for DateTime, in dd/MM/yyyy) to dd/MM/yyyy?
    string result = (new DateTime(1,1,1) ).AddDays(x).To String("dd/MM/yyyy");


    Comment

    • =?Utf-8?B?TW9ydGVuIFdlbm5ldmlrIFtDIyBNVlBd?=

      #3
      RE: System.DateTimi e

      Hi,

      1)
      To creat a DateTime object given as x days since January 1st 0001 use

      DateTime dt = DateTime.MinVal ue.AddDays(nume rOfDays);

      2)
      A date is stored internally independent of any culture. If you want to
      output the date in a specific culture format, you can use that culture's
      DateTimeFormat

      DateTime.Now.To String(System.G lobalization.Cu ltureInfo.GetCu ltureInfo("nb-NO");

      The above will print dates with Norwegian formatting.

      --
      Happy Coding!
      Morten Wennevik [C# MVP]


      "AA2e72E" wrote:
      I am struggling a little with these 2 problems:
      >
      1. How can I convert an integer, representing x days from 01/01/0001 (the
      minimum value for DateTime, in dd/MM/yyyy) to dd/MM/yyyy?
      2. Is there any functionality for converting a date from one locale to
      another?
      >
      Thanks for your help.

      Comment

      Working...