Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Feb 21, 2013 08:07 PM by Rion Williams
Feb 21, 2013 07:51 PM|LINK
I would like to use date format specifier "F" but strip out the day of the week. Is this possible? In other words I want my date/time to render as: June 15, 2013 12:05 PM (I don't need the seconds either). This is my code to show how I'm getting the
Feb 21, 2013 07:53 PM|LINK
Use a custom format string and you'll have full control. Google/Bing custom datetime formatting.
Feb 21, 2013 07:59 PM|LINK
If you don't want the name of the day and the seconds, you could use the following formatting string :
//This will output February 21, 2013 15:00 PM
DateTime.Now.ToString("MMMM dd, yyyy HH:mm tt");
So for your usage :
<%=System.IO.File.GetLastWriteTime(Request.PhysicalPath).ToString("MMMM dd, yyyy HH:mm tt")%>
Read more about DateTime Formatting here.
Feb 21, 2013 08:05 PM|LINK
Thanks. I'm aware of this page
http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx ; I'm trying to figure out if there is a way to make it not a 24 hour clock, such that 13:00 will render as 01:00 PM or 1:00 PM
Feb 21, 2013 08:07 PM|LINK
Just use 'h' instead of 'HH' to avoid the 24-Hour Clock.
//This will output "February 21, 2013 3:07 PM"
DateTime.Now.ToString("MMMM dd, yyyy h:mm tt");
and for your usage :
<%=System.IO.File.GetLastWriteTime(Request.PhysicalPath).ToString("MMMM dd, yyyy h:mm tt")%>