Usage demonstration of PHP Date Formatter library. Configure the input datetime field and other available PHP date formatter settings to check your formatted output.
Not seeing the updated content on this page! Hard refresh your browser to clean cache for this page (e.g. SHIFT-F5 on Windows Chrome)
var fmt = new DateFormatter(), fmts = [ 'd', 'D', 'j', 'l', 'N', 'w', 'z', 'W', 'F', 'm', 'M', 'n', 't', 'L', 'o', 'Y', 'y', 'a', 'A', 'B', 'g', 'G', 'h', 'H', 'i', 's', 'u', 'e', 'I', 'O', 'P', 'T', 'Z', 'c', 'r', 'U' ], kvSetFmt = function() { var dtParsed, dtFormatted, out = ''; dtParsed = fmt.parseDate($("#input-date").val(), $("#input-format").val()); $("#parsed-date").val(dtParsed); dtFormatted = fmt.formatDate(dtParsed, $("#output-format").val()); $("#formatted-date").val(dtFormatted); if (!dtParsed) { $('#format-samples').html('<div class="alert alert-danger">' + '<h4>Error</h4>Cannot parse source date</div>'); return; } $.each(fmts, function(i, f) { out += '<tr><td><code>' + f + '</code></td><td><samp>' + fmt.parseFormat(f, dtParsed) + '</samp></td></tr>'; }); $('#format-samples').html( '<table class="table table-bordered table-hover">' + '<tr><td colspan=2><h4 class="text-muted">Date Format Patterns</h4></td></tr>' + '<tr class="table-active"><th>Format</th><th>Value</th></tr>' + out + '</table>'); }; kvSetFmt(); $("#input-date, #input-format, #output-format").on("change", function() { kvSetFmt(); });
Comments & Discussion
Note
You can now visit the Krajee Webtips Q & A forum for searching OR asking questions OR helping programmers with answers on these extensions and plugins. For asking a question click here. Select the appropriate question category (i.e. Krajee Plugins) and choose this current page plugin in the question related to field.
The comments and discussion section below are intended for generic discussions or feedback for this plugin. Developers may not be able to search or lookup here specific questions or tips on usage for this plugin.