Please let me know how can I can get the current date and time in this format:
Friday, November 18, 2011 7:00 PM
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Sure:
Mind you, you may well want to use one of the standard date/time format strings instead of a custom one like this. This is fundamentally a human-readable form, which should usually take account of the culture of the user it’s going to be displayed to.
As dahlbyk mentioned,
InvariantCultureis usually for machine-to-machine formatting, like custom format strings, which is why I’ve used it here. If this is for human consumption but you always want it in US English, then you should specify a US culture. You may still want to specify the custom format string instead of using a standard format string if you want to make it clearer in your code (or simpler to change) later. But you really ought to work out whether this is meant to be used by humans or machines.