connector needs Date/time in yyyyMMddTHH:mm:ss+0000 format
Hi all,
I am building another connector which needs date formatted <yyyyMMddTHH:mm:ss+0000>
The year as a 4-digit decimal number including century, followed by the month as a decimal number with a range of 01–12, followed by the day of the month as a decimal number with a range of 01–31, followed by a character T, followed by the hour as a decimal number using a 24-hour clock with a range of 00–23, followed by the minute as a decimal number with a range of 00–59, followed by the second as a decimal number with a range of 00–60, followed by the timezone as hours offset from GMT. An example timestamp would be 20130703T19:38:41+0000.
I can get the date but not in the correct format.
Can anyone help please.
Thanks
Best Answer
-
Hi,
This is assuming you want the current date and time:
var date = new Date();
var year = date.getYear()+1900;
var month = (date.getMonth() < 10)? '0' + date.getMonth() : date.getMonth();
var day = (date.getDate() < 10)? '0' + date.getDate() : date.getDate();
var hours = (date.getHours() < 10)? '0' + date.getHours() : date.getHours();
var minutes = (date.getMinutes() < 10)? '0' + date.getMinutes() : date.getMinutes();
var seconds = (date.getSeconds() < 10)? '0' + date.getSeconds() : date.getSeconds();
var timezone = date.getTimezoneOffset();var formattedDate = year + '' + month + '' + day + 'T' + hours + ':' + minutes + ':' + seconds + '' + timezone;
console.log(formattedDate);
Let me know how you go
Cheers
Eric
0
Answers
-
Hi,
This is assuming you want the current date and time:
var date = new Date();
var year = date.getYear()+1900;
var month = (date.getMonth() < 10)? '0' + date.getMonth() : date.getMonth();
var day = (date.getDate() < 10)? '0' + date.getDate() : date.getDate();
var hours = (date.getHours() < 10)? '0' + date.getHours() : date.getHours();
var minutes = (date.getMinutes() < 10)? '0' + date.getMinutes() : date.getMinutes();
var seconds = (date.getSeconds() < 10)? '0' + date.getSeconds() : date.getSeconds();
var timezone = date.getTimezoneOffset();var formattedDate = year + '' + month + '' + day + 'T' + hours + ':' + minutes + ':' + seconds + '' + timezone;
console.log(formattedDate);
Let me know how you go
Cheers
Eric
0 -
Hi, great thanks. The timezone offset is coming back as -60 instead of -0060 but I can hard code that. Otherwise great thanks
0
Categories
- All Categories
- 1.8K Product Ideas
- 1.8K Ideas Exchange
- 1.6K Connect
- 1.2K Connectors
- 300 Workbench
- 6 Cloud Amplifier
- 9 Federated
- 2.9K Transform
- 102 SQL DataFlows
- 626 Datasets
- 2.2K Magic ETL
- 3.9K Visualize
- 2.5K Charting
- 753 Beast Mode
- 61 App Studio
- 41 Variables
- 692 Automate
- 177 Apps
- 456 APIs & Domo Developer
- 49 Workflows
- 10 DomoAI
- 38 Predict
- 16 Jupyter Workspaces
- 22 R & Python Tiles
- 398 Distribute
- 115 Domo Everywhere
- 276 Scheduled Reports
- 7 Software Integrations
- 130 Manage
- 127 Governance & Security
- 8 Domo Community Gallery
- 38 Product Releases
- 11 Domo University
- 5.4K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 110 Community Announcements
- 4.8K Archive