System.DateTimie

  • Thread starter Thread starter AA2e72E
  • Start date Start date
A

AA2e72E

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.
 
AA2e72E said:
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).ToString("dd/MM/yyyy");
 
Hi,

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

DateTime dt = DateTime.MinValue.AddDays(numerOfDays);

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.ToString(System.Globalization.CultureInfo.GetCultureInfo("nb-NO");

The above will print dates with Norwegian formatting.
 
Back
Top