Click here to Skip to main content
12,952,159 members (60,280 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
how to display date in dd/mm/yyyy format

I have a label with name lbldate

so iam writing my code as lbldate.Text=System.DateTime.Now.ToShortDateString();
it is displaying as 1/15/2013.

But,

I need it as 15/1/2013 (day month year) Format.

Please give me a good Solution. Thanks in Advance.
Posted 14-Jan-13 20:48pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

If you use a standard format, the result depends on the culture that is set for the machine executing the code (which I suspect will be the Server in your case, not the Client). If you want a specific data format, then you need to specify exactly what you want:
lbldate.Text=System.DateTime.Now.ToString("dd/MM/yyyy"); 
And the Culture will be ignored.

There is a list of the format strings here: Formatting a DateTime for display - format string description[^]
  Permalink  
Comments
Ranjith Reddy CSE 15-Jan-13 2:56am
   
Thanks...............
OriginalGriff 15-Jan-13 3:01am
   
You're welcome!
Member 11993344 18-Sep-15 12:37pm
   
x
__TR__ 15-Jan-13 2:57am
   
+5
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

For example, System.DateTime.Now.ToString("dd/mm/yyyy"); please see:
http://msdn.microsoft.com/en-us/library/zdtaw1bw.aspx[^],
http://msdn.microsoft.com/en-us/library/az4se3k1.aspx[^],
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx[^].

You can also use the particular culture with this date format:
http://msdn.microsoft.com/en-us/library/ht77y576.aspx[^].

—SA
  Permalink  
Comments
__TR__ 15-Jan-13 2:55am
   
+5
   
Thank you.
—SA
Ranjith Reddy CSE 15-Jan-13 2:56am
   
Thanks...............
   
You are welcome.
—SA
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Try
lbldate.Text = DateTime.Now.ToString("dd/MM/yyyy");
  Permalink  
Comments
Ranjith Reddy CSE 15-Jan-13 2:56am
   
Thanks...............
__TR__ 15-Jan-13 6:36am
   
You are welcome.
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 4

Hello

You Can use
System.DateTime.Now.ToShortDateString();

it gives your system Short Date time thats why it would give you.
1/15/2013
if you change your System or server time setting than it will give you write Time As you Want and either case you can simple use
lbldate.Text = DateTime.Now.ToString("dd/MM/yyyy");
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,239
CHill60 3,490
Maciej Los 3,083
Jochen Arndt 1,975
ppolymorphe 1,880


Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 15 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100