Today i have task to do some date formating in DataGrid. So i think its easy but you don’t belive that its easy only when you remember the formating character.
Which i don’t really remember always and it is true. so for this purpose i am putting some format string here so at least i will get benifit in future.
Before starting i want to say if you are using type dataset for binding the grid please check your date column’s data type by mistake i did it string so be remember it should be date. here firstly we talk about time so here i goes.
h :- Displays the hour like (1,2,…12) remember limit & its mainly use with AM/PM format
hh :-Displays the hour like (01,02,…12) remember limit & its mainly use with AM/PM format
H :- It also display hours but diffrence is limit goes up to 23 like (1,2,3,….23) & not used with AM/PM format
HH :- It is same as H but diffrence is it start with 0 if number is less than double digit.
m :-Display the minutes.
mm :- it always show minutes in two digits.
s:- show seconds
ss:- Show seconds in always 2 digit like 00,01,02,…59
t :- it display first character of AM/PM
tt:- it Display either AM or PM
M:- it denotes month start from 0 – 12.
MM :- it also shows month but in double digit 01,…12
MMM :- shows month in 3 character like JAN, FEB
MMMM (+): Shows month with full name.
yy:- it show year last two digit
yyyy:- its show year like 1998, or we can say in 4 digit.
d :- Shows current day of the month.
dd:-It shows day in 2 digit always like 01,
ddd:- Show’s 3 character of the day like MON , TUE
dddd(+):- show full day character
exmaple x.ToString(“0:MM/dd/yy hh:mm:sstt)