I am trying to convert a UTC date that currently looks like <span class="enrolldate">2011-10-01 22:00:00</span>
simply to a M/D/YYYY date format with date.js. Can someone help? Thanks!
From the API for date.js, you can output the format you require with:
Date.today().toString("M/d/yyyy"); // 11/19/2007
Related
Want to change my input type date format dddd, dd-MM-yyyy.
Any update or guidance?
try input tostring("yyyy-MM-dd") but it is default format.
Actually, I am using an asp boilerplate platform. I found that the platform only follows this date format 'yyyy-MM-dd. And this is working.
I'll have to save various working hours (open and closes) and wonder what is the best format/way to use ?
Sure I can choose to have time time as DB type for these values and format the DB time like that:
Time.current.to_s(:time)
=> "15:52"
Instead of Time.current I'll be select the corresponding time value from the DB:
Thu, 12 Apr 2018 15:48:28 UTC +00:00
But what is solution to choose for a User to enter time values in the front-end ? Moreover, I'll have to either choose a general format for hours, like
07:30
Or (it the requirement changes) enable a locale-dependent format like this:
7ч30 (for Russia)
7h30 (for France)
etc..
Any ideas and tips ? Thank you.
I'd store "seconds from midnight", so 15:52 would be stored as the integer 57120. Then I'd write a custom type see the attribute docs for more details that converts to/from that integer.
Then I'd just have different formats in the locale file that I'd use for that conversion.
I wish to format my date (22/03/2016 23:59:59) to string with milliseconds.
dr.GetDateTime(1).ToString("yyyy-MM-dd hh:mm:ss")
.ToString("yyyy-MM-dd")
.ToString("hh':'mm':'ss")
If you google DateTime.ToString(), you end up with MSDN documentation explaining this function.
Then you can find a link to Custom Date and Time Format, which explains that to display milliseconds, you must do this :
dr.GetDateTime(1).ToString("yyyy-MM-dd hh:mm:ss fff")
How can i check the system date format? Tried with the code below, but when i change my system's date format to another date format to test the code, it's still showing the date format before changed!
System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern()
Ok. I managed to find the solution, the 'CurrentCulture' has to be 'CurrentUICulture', instead of CurrentCulture. Which is as below:
System.Globalization.CultureInfo.CurrentUICulture.DateTimeFormat.ShortDatePattern()
I am trying to format dates in an HTML cfgrid. I cannot seem to make it work in CF when using HTML as the grid type. I have also tried doing it in MSSQL by using - CONVERT(VARCHAR(10), startDate, 101) AS startDate.
When I do that it shows up right in the grid but the grid will not sort on the date properly.
I understand why converting it to varchar screws up the sort but I cannot seem to make this work in either CF or SQL.
Anyone know of a way to make it show up in the grid in a mm/dd/yyyy format and also sort on the date properly?
Ability to use the mask attribute in html grids was added in CF9. To get it to work on dates you also have to specify type=date
<cfgridcolumn mask="m/d/Y" type="date" ... >
If you are using an html cfgrid, you need to use the formats found in the Ext JS Date class. NOT the date format for Flash.
Here is a link to the Ext JS Date class
<cfgridcolumn ... mask="mm/dd/yy">
source