https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl
const now = Intl.DateTimeFormat('de', {
dateStyle: 'medium',
timeStyle: 'medium'
}).format( Date.now() )
console.log( now )
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl
const now = Intl.DateTimeFormat('de', {
dateStyle: 'medium',
timeStyle: 'medium'
}).format( Date.now() )
console.log( now )
Using regex, you can simply reorder the parts of your date string to create a compatible ISO 8601 date string which is accepted by the new Date()
constructor.
const date_string = "20220101"
const oDate = new Date(date_string.replace(/(\d{4})(\d{2})(\d{2})/, '$1-$2-$3'))
console.log(oDate.toUTCString())
Using regex, you can simply reorder the parts of your date string to create a compatible ISO 8601 date string which is accepted by the new Date()
constructor.
const date_string = "01.01.2022"
const oDate = new Date(date_string.replace(/(.*)\.(.*)\.(.*)/, '$3-$2-$1'))
console.log(oDate.toUTCString())
const start = new Date()
const end = new Date()
start.setHours(0, 0, 0, 0)
end.setHours(23, 59, 59, 999)
console.log(start.toISOString())
console.log(end.toISOString())
//Input String yyyymmdd
var date_string = '20200101'
//Create date object
var oDate = new Date(date_string.substr(0, 4), date_string.substr(4, 2), date_string.substr(6, 2))
oDate.setMonth(oDate.getMonth() - 1)
var year = oDate.getFullYear().toString()
var month = oDate.getMonth().toString()
var day = oDate.getDay().toString()
//Add leading zero's
if (month.length === 1 ) {
month = '0' + month
}
if (day.length === 1 ) {
day = '0' + day
}
//Return string: 20191201
var sDate = year + month + day
https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abapcompute_string_format_options.htm
DATA(l_date) = |{ sy-datum COUNTRY = 'DE ' }| "result 01.01.2020
DATA(l_time) = |{ sy-uzeit COUNTRY = 'DE ' }| "result 08:00
"another way
DATA(l_date) = |{ sy-datum DATE = ENVIRONMENT }|.
DATA(l_time) = |{ sy-uzeit TIME = ENVIRONMENT }|.