I have got a timestamp that consists of date and time, something like "YYYYMMddhhmmss" and I want to display it as a datetime in the Fiori frontend like "Month dd, YYYY hh:mm PM" and enable the auto DateTimePicker.
While there are the tstmp_to_dats and tstmp_to_tims functions available in a CDS view that work fine for individual dates or times I couldn't figure out how to create a DateTime. What is the correct way?
the correct way is to format the datetime in the Fiori stack.
Specify valueFormat
and displayFormat
of DateTimePicker
.
<DateTimePicker value="20170909103032" valueFormat="yyyyMMddHHmmss" displayFormat="MM dd, yyyy HH:mm a" />
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<script id="sap-ui-bootstrap" type="text/javascript" src="https://openui5.hana.ondemand.com/resources/sap-ui-core.js" data-sap-ui-libs="sap.m" data-sap-ui-theme="sap_belize" data-sap-ui-xx-bindingSyntax="complex">
</script>
<script id="view1" type="sapui5/xmlview">
<mvc:View xmlns="sap.m" xmlns:mvc="sap.ui.core.mvc" xmlns:core="sap.ui.core">
<DateTimePicker value="20170909103032" valueFormat="yyyyMMddHHmmss" displayFormat="MM dd, yyyy HH:mm a" />
</mvc:View>
</script>
<script>
var myView = sap.ui.xmlview({
viewContent: jQuery('#view1').html()
}); // accessing the HTML inside the script tag above
myView.placeAt('content');
</script>
</head>
<body id='content' class='sapUiBody'>
</body>
</html>