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

Using DateFormatter on a Unix timestamp

You can convert unixTimestamp to date using Date(timeIntervalSince1970:). let unixTimestamp = 1480134638.0 let date = Date(timeIntervalSince1970: unixTimestamp) If you want to display date in string with specific formate than you can use DateFormatter like this way. let date = Date(timeIntervalSince1970: unixtimeInterval) let dateFormatter = DateFormatter() dateFormatter.timeZone = TimeZone(abbreviation: “GMT”) //Set timezone that you want dateFormatter.locale … Read more

datetime to string with time zone

Use the “zzz” format specifier to get the UTC offset. For example: var dt = new DateTime(2010, 1, 1, 1, 1, 1, DateTimeKind.Utc); string s = dt.ToLocalTime().ToString(“yyyy-MM-dd HH:mm:ss \”GMT\”zzz”); Console.WriteLine(s); Output: 2009-12-31 19:01:01 GMT-06:00 I’m in the CDT timezone. Make sure the DateTime is unambiguously DateTimeKind.Utc.

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>