In the Django admin site, how do I change the display format of time fields?

Try this in the ModelAdmin: def time_seconds(self, obj): return obj.timefield.strftime(“%d %b %Y %H:%M:%S”) time_seconds.admin_order_field = ‘timefield’ time_seconds.short_description = ‘Precise Time’ list_display = (‘id’, ‘time_seconds’, ) Replacing “timefield” with the appropriate field in your model, of course, and adding any other needed fields in “list_display”.

Time ISO 8601 in Ruby

You can use strftime yourself and create the format you want as described here The format you specified should be %Y-%m-%dT%H:%M:%S.%L%z And so the complete Ruby statement would be Time.now.strftime(‘%Y-%m-%dT%H:%M:%S.%L%z’) Various ISO 8601 formats: %Y%m%d => 20071119 Calendar date (basic) %F => 2007-11-19 Calendar date (extended) %Y-%m => 2007-11 Calendar date, reduced accuracy, specific month … Read more

Convert string to date in my iPhone app

Take a look at the class reference for NSDateFormatter. You use it like this: NSString *dateStr = @”Tue, 25 May 2010 12:53:58 +0000″; // Convert string to date object NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat:@”EE, d LLLL yyyy HH:mm:ss Z”]; NSDate *date = [dateFormat dateFromString:dateStr]; [dateFormat release]; For more information on how to … Read more

Parse date in MySQL

You may want to use the STR_TO_DATE() function. It’s the inverse of the DATE_FORMAT() function. STR_TO_DATE(str,format) This is the inverse of the DATE_FORMAT() function. It takes a string str and a format string format. STR_TO_DATE() returns a DATETIME value if the format string contains both date and time parts, or a DATE or TIME value … Read more

How to insert date values into table

Since dob is DATE data type, you need to convert the literal to DATE using TO_DATE and the proper format model. The syntax is: TO_DATE(‘<date_literal>’, ‘<format_model>’) For example, SQL> CREATE TABLE t(dob DATE); Table created. SQL> INSERT INTO t(dob) VALUES(TO_DATE(’17/12/2015′, ‘DD/MM/YYYY’)); 1 row created. SQL> COMMIT; Commit complete. SQL> SELECT * FROM t; DOB ———- … Read more

Format Date output in JSF

Use <f:convertDateTime>. You can nest this in any input and output component. Pattern rules are same as java.text.SimpleDateFormat. <h:outputText value=”#{someBean.dateField}” > <f:convertDateTime pattern=”dd.MM.yyyy HH:mm” /> </h:outputText>

`uuuu` versus `yyyy` in `DateTimeFormatter` formatting pattern codes in Java?

Within the scope of java.time-package, we can say: It is safer to use “u” instead of “y” because DateTimeFormatter will otherwise insist on having an era in combination with “y” (= year-of-era). So using “u” would avoid some possible unexpected exceptions in strict formatting/parsing. See also this SO-post. Another minor thing which is improved by … Read more

Date formatting in WPF datagrid

Don`t forget to use DataGrid.Columns, all columns must be inside that collection. In my project I format date a little bit differently: <tk:DataGrid> <tk:DataGrid.Columns> <tk:DataGridTextColumn Binding=”{Binding StartDate, StringFormat=\{0:dd.MM.yy HH:mm:ss\}}” /> </tk:DataGrid.Columns> </tk:DataGrid> With AutoGenerateColumns you won`t be able to contol formatting as DataGird will add its own columns.