How do I format a date as ISO 8601 in moment.js?

moment().toISOString(); // or format() – see below http://momentjs.com/docs/#/displaying/as-iso-string/ Update Based on the answer: by @sennet and the comment by @dvlsg (see Fiddle) it should be noted that there is a difference between format and toISOString. Both are correct but the underlying process differs. toISOString converts to a Date object, sets to UTC then uses the … Read more

Compare two date formats in javascript/jquery

It’s quite simple: if(new Date(fit_start_time) <= new Date(fit_end_time)) {//compare end <=, not >= //your code here } Comparing 2 Date instances will work just fine. It’ll just call valueOf implicitly, coercing the Date instances to integers, which can be compared using all comparison operators. Well, to be 100% accurate: the Date instances will be coerced … Read more

PHP Fatal error: Call to a member function format() on boolean

Neither example work as you have multiple errors: You forgot your second parameter to Datetime::createFromFormat() h:i:s should be H:i:s Your date in the second example is separated by a . not a – Fixes: <?php $date = “13-06-2015 23:45:52”; echo DateTime::createFromFormat(‘d-m-Y H:i:s’, $date)->format(‘Y-m-d h:i:s’); $date = “10.06.2015 09:25:52”; echo DateTime::createFromFormat(‘d.m.Y H:i:s’, $date)->format(‘Y-m-d h:i:s’); ?>

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>

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.

Is there a built-in function or plugin to handle date formatting in JavaScript?

No, there is nothing built-in for Dateobjects, but there are a bunch of libraries to deal with and format them: date.js moment.js XDate Date and Date.Extras in Mootools Date in Sugar Dojo.date a few functions in Mochikit DateFormat (only PHP’s date) date at php.js DataType in YUI, especially for i18n date-functions.js, used especially by JQuery … Read more