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
date/time now.
run4it
Member
44 Points
288 Posts
Date and Time Format Strings
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 date/time now.
<%=System.IO.File.GetLastWriteTime(Request.PhysicalPath).ToString("F")%>
MetalAsp.Net
All-Star
112085 Points
18242 Posts
Moderator
Re: Date and Time Format Strings
Feb 21, 2013 07:53 PM|LINK
Use a custom format string and you'll have full control. Google/Bing custom datetime formatting.
Rion William...
All-Star
27134 Points
4497 Posts
Re: Date and Time Format Strings
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.
run4it
Member
44 Points
288 Posts
Re: Date and Time Format Strings
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
Rion William...
All-Star
27134 Points
4497 Posts
Re: Date and Time Format Strings
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")%>