Visual C++ .NET/Data Type/DateTime
Create DateTime
#include "stdafx.h"
using namespace System;
using namespace System::Collections;
int main()
{
array<DateTime^>^ dateArray = gcnew array<DateTime^>(2);
dateArray[0] = gcnew DateTime(1970, 12, 18);
dateArray[1] = gcnew DateTime(1990, 1, 5);
IEnumerator^ enumerator1 = dateArray->GetEnumerator();
while ( enumerator1->MoveNext() )
{
DateTime^ current = (DateTime^) enumerator1->Current;
Console::WriteLine( current->ToString("MM/dd/yyyy") );
}
}
DateTime array
#include "stdafx.h"
using namespace System;
using namespace System::Collections;
int main()
{
array<DateTime^>^ dateArray = gcnew array<DateTime^>(2);
dateArray[0] = gcnew DateTime(1970, 12, 18);
dateArray[1] = gcnew DateTime(1990, 1, 5);
IEnumerator^ enumerator1 = dateArray->GetEnumerator();
while ( enumerator1->MoveNext() )
{
DateTime^ current = (DateTime^) enumerator1->Current;
Console::WriteLine( current->ToString("MM/dd/yyyy") );
}
}
Multicultural Dates
#include "stdafx.h"
using namespace System;
using namespace System::Globalization;
void main()
{
DateTime dt = DateTime::Now;
Console::WriteLine("en-us {0}",dt.ToString("D",gcnew CultureInfo("en-us")));
Console::WriteLine("en-gb {0}",dt.ToString("D",gcnew CultureInfo("en-gb")));
Console::WriteLine("fr-fr {0}",dt.ToString("D",gcnew CultureInfo("fr-fr")));
Console::WriteLine("de-de {0}",dt.ToString("D",gcnew CultureInfo("de-de")));
}