Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET3.5 VB.NET WinForm
Hi Guys I tried that requirement I got the error as "Input string was not in a correct format".
 
I want the date format like this "Thursday, August 30, 2007 11:19:59 AM". how can do this in windows form.
 
I was tried as
 
private void Form1_Load(object sender, EventArgs e)
        {
            label1.Text =  string.Format("{r}", System.DateTime.Now);
        }
 

 
Here r is specifier.
Posted 9-Oct-12 19:16pm
Edited 9-Oct-12 19:18pm
v3
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

hi, try this:
private void Form1_Load(object sender, EventArgs e)
        {
            label1.Text =  System.DateTime.Now.ToString("F");
        }
  Permalink  
Comments
CH Guravaiah at 10-Oct-12 1:31am
   
thank you
tanweer akhtar at 10-Oct-12 1:45am
   
mark as answer if it solves your problem
Andy411 at 10-Oct-12 1:53am
   
Thx, you have brought me the ToString(string format) method back in mind :-)
tanweer akhtar at 10-Oct-12 1:58am
   
:p
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Hi,
 
take a look at DateTime.ToLongDateString() and ToLongTimeStamp()
 
DateTime d = DateTime.Now;
string s = d.ToLongDateString() + " " + d.ToLongTimeString();
In en-US it will result in
Wednesday, October 10, 2012 7:44:40 AM
 
and in de-DE it will result in
Mittwoch, 10. Oktober 2012 07:46:56
 
If you're using these methods, the time format will allways be correct regarding the current culture.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try :
label1.Text = DateTime.Now.ToString("dddd, MMMM dd, yyyy hh:MM:ss");
  Permalink  

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

  Print Answers RSS
0 Gihan Liyanage 332
1 Sergey Alexandrovich Kryukov 265
2 ClimerChinna 222
3 vikinghunter 188
4 OriginalGriff 161
0 Sergey Alexandrovich Kryukov 8,363
1 OriginalGriff 7,112
2 CPallini 2,598
3 Richard MacCutchan 2,025
4 Abhinav S 1,788


Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 10 Oct 2012
Copyright © CodeProject, 1999-2014
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