• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Date format

New Here ,
May 08, 2020 May 08, 2020

Copy link to clipboard

Copied

I am using variables to apply the date to the course, but the client would like 05/08/2020 and the different date formats I've tried in variables will not give me the 0 in front of the day, if needed.  Is this possible?

Views

497

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 14, 2020 May 14, 2020

Copy link to clipboard

Copied

Mak a new variable with a pre value:

DateFormat = DDMMYYYY

And use cpInfoCurrentDateStringDDMMYYYY

/Jacob

 

(And if the Month first)

 

DateFormat = MMDDYYYY

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 14, 2020 May 14, 2020

Copy link to clipboard

Copied

Or 

 

var d = new Date();
var s = '';
s = d.getDate()+'/'+(d.getMonth()+1)+'/'+d.getFullYear();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 14, 2020 May 14, 2020

Copy link to clipboard

Copied

var s = '';
s = d.getDate()+'/'+(d.getMonth()+1)+'/'+d.getFullYear(); //withOUT leading zeros
var date = new Date('4-1-2015'); // M-D-YYYY
 
var d = date.getDate();
var m = date.getMonth() + 1;
var y = date.getFullYear();
var dateString = (d <= 9 ? '0' + d : d) + '-' + (m <= 9 ? '0' + m : m) + '-' + y; //WITH leading zeros

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
May 14, 2020 May 14, 2020

Copy link to clipboard

Copied

Use this instead of a single date variable

 

$$cpInfoCurrentDate$$/$$cpInfoCurrentMonth$$/$$cpInfoCurrentYear$$

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 14, 2020 May 14, 2020

Copy link to clipboard

Copied

LATEST

Doh...

I misread it. Thought it was about REMOVING the zeroes 😉

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Help resources