CipherIS
asked on
C# Format Date Time
This is prob an easy question but I am having issue. I need to print date time in the following format.
Input -> Date Jan 14, 2013 Time 1:02 pm
Output -> 20130114 1302
I used below but it just prints
yyyyMMddHHmm
string.Format("yyyy", DateTime.Now.Year) +
string.Format("MM", DateTime.Now.Month) +
string.Format("dd", DateTime.Now.Day)
string.Format("HH", DateTime.Now.TimeOfDay.Hou rs) + string.Format("mm", DateTime.Now.TimeOfDay.Min utes)
Input -> Date Jan 14, 2013 Time 1:02 pm
Output -> 20130114 1302
I used below but it just prints
yyyyMMddHHmm
string.Format("yyyy", DateTime.Now.Year) +
string.Format("MM", DateTime.Now.Month) +
string.Format("dd", DateTime.Now.Day)
string.Format("HH", DateTime.Now.TimeOfDay.Hou
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Figured it out
You could do this:
string.Format("Date {0} {1}, {2} Time {3}:{4}", DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Year, DateTime.Now.TimeOfDay.Hou