Formatting date without years

Hi,
I need to display in my app the birthday but without the years.
I use the Date Format plugin but it is not in the localised format (french)

Is there a way to do it ?

Thanks

I used JavaScript for this.

function formatDateTimeTZ(datetimeString) {
  // Step 1: Parse the datetime string into a Date object
  const date = new Date(datetimeString);
  
  // Step 2: Set the locale to French and format the date
  const options = {
    day: '2-digit',
    month: 'long',
    year: 'numeric', // Include year to ensure correct date interpretation
    timeZone: 'UTC'  // If needed, adjust the timezone
  };
  
  // Step 3: Format the date
  const formattedDate = date.toLocaleDateString('fr-FR', options);
  
  // Extract only "DD MMMM" from the formatted string
  // The formatted string includes the year, so we need to remove it
  const parts = formattedDate.split(' ');
  const day = parts[0];
  const month = parts[1];
  return `${day} ${month}`;
}

return formatDateTimeTZ(p1)

With p1 being your “Birthday” column.

4 Likes

Thank you but I’m on a Legacy Free :confused:

JavaScript is available on free plan.

Ho yes, I’ve just found it

Thank you :pray:

1 Like

Please, give the Solution mark to Thin! :slight_smile: Not to me.

1 Like

I don’t understand why the dates don’t match :weary:

It is probably because of UTC time conversion. What is your timezone?

1 Like

I’m in France

I’ve change UTC to CET and it seems working

2 Likes

There we go :smiley: All good then?

We will see tomorrow :sweat_smile:

1 Like

Good to see :wink:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.