...
If you want to format a date or datetime based on culture, you can use Aptify.framework.utility.getFormattedDateTime()
Code Block language js title Get Formatted Current Date/Time linenumbers true // Returns the current date and time as a string formatted for the user's Culture. Aptify.framework.utility.getFormattedDateTime(new Date());
Code Block language js title Get Formatted Date/Time linenumbers true // Takes a valid JSON-formatted date or datetime and returns it as a string formatted for the user's Culture. Aptify.framework.utility.getFormattedDateTime("2014-09-09T12:07:12.878Z");
If you want to turn an already-formatted date (or datetime) into a JavaScript Date object without time information, you can use Aptify.framework.utility.getCultureDate().
Code Block language js title Parse a Formatted Date/Time String linenumbers true // Returns a JavaScript Date object, with the time information stripped out Aptify.framework.utility.getCultureDate("09/09/2014 05:37:12 PM") // Returns a JavaScript Date object Aptify.framework.utility.getCultureDate("12/09/2014") // So for both these calls, the time portion of the output is 00:00:00
Code Block language js title Parse an Invalid Formatted Date/Time String linenumbers true // Invalid date/time when the DateFormat is "MM/dd/yyyy"; returns null Aptify.framework.utility.getCultureDate("13/09/2014 05:37:12 PM")
If you want to turn an already-formatted datetime into a JavaScript Date object with time information, you can use Aptify.framework.utility.getCultureDateTime().
Code Block language js title Parse a Formatted Date/Time String linenumbers true // Returns a JavaScript Date object Aptify.framework.utility.getCultureDateTime("09/09/2014 05:37:12 PM")
Code Block language js title Parse an Invalid Formatted Date/Time String linenumbers true // Invalid datetime, since it does not include time information; returns null Aptify.framework.utility.getCultureDateTime("13/09/2014 05:37:12 PM")
If you want to turn a JavaScript Date object into a JSON-formatted datetime string, you can use Aptify.framework.utility.getJSONDateTime().
Code Block language js title Get JSON-Formatted String From JavaScript Date Object linenumbers true // Returns a JSON-formatted string representation of the current date and time Aptify.framework.utility.getJSONDateTime(new Date());
Tip You can go through getCultureDateTime() to use getJSONDateTime() on a culture-formatted datetime:
Code Block language js title Get JSON-Formatted String From Culture-Formatted String linenumbers true // Returns a JSON-formatted string representation of the culture-formatted datetime Aptify.framework.utility.getJSONDateTime(Aptify.framework.utility.getCultureDateTime("12/09/2014 05:37:12 PM"));
Related articles
Filter by label (Content by label) | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|