Changing the Date format from json Data | Community
Skip to main content
Level 2
February 4, 2025
Solved

Changing the Date format from json Data

  • February 4, 2025
  • 1 reply
  • 411 views

Hi 

We are having JSON data having Transaction Date attribute but the values in format of 20250122160808(YYYYMMDDHHRRSS).

So i need to change to (for Eg 2025-01-22 16:10:58) YYYY-MM-DD HH:RR:SS This format.

How i can achieve this using JS code.


This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by ParthaSarathy

Hi @vanivi1 ,

You can try the below,

vars.jsonTime= '20250122160808'; vars.DateFormat = vars.jsonTime.substr(0,4)+'/'+vars.jsonTime.substr(4,2)+'/'+vars.jsonTime.substr(6,2)+' '+vars.jsonTime.substr(8,2)+':'+vars.jsonTime.substr(10,2)+':'+vars.jsonTime.substr(12,2); logInfo("jsonTime: "+vars.jsonTime); logInfo("DateFormat: "+vars.DateFormat);

1 reply

ParthaSarathy
Community Advisor
ParthaSarathyCommunity AdvisorAccepted solution
Community Advisor
February 4, 2025

Hi @vanivi1 ,

You can try the below,

vars.jsonTime= '20250122160808'; vars.DateFormat = vars.jsonTime.substr(0,4)+'/'+vars.jsonTime.substr(4,2)+'/'+vars.jsonTime.substr(6,2)+' '+vars.jsonTime.substr(8,2)+':'+vars.jsonTime.substr(10,2)+':'+vars.jsonTime.substr(12,2); logInfo("jsonTime: "+vars.jsonTime); logInfo("DateFormat: "+vars.DateFormat);
 ~  ParthaSarathy S~  Click here to join ADOBE CAMPAIGN USER GROUP for Quarterly In-person | Hybrid | Virtual Meetups