Skip to main content
Solved

Current date plugin

  • January 28, 2022
  • 5 replies
  • 7619 views

Gabriel_Leni

Does anybody know of a plugin that allows you to add current date in dd/mm/yy format in a textbox? I’ve just tried Powerful Tools, but only adds a random date. Thank you!

Best answer by tank666

I don’t know if Figma Community has such a plugin, but you can use the open source plugin:

GitHub
View original
This topic has been closed for comments

5 replies

tank666
  • 4868 replies
  • Answer
  • January 28, 2022

I don’t know if Figma Community has such a plugin, but you can use the open source plugin:

GitHub

ntfromchicago

@Gabriel_Leni With the Scripter plugin, you can use this code snippet to place the date into any selected text box.

for (const node of figma.currentPage.selection) {
	if (node.type === 'TEXT') {

		const date = new Date();

		// Edit this array to display months in a different format
		const monthArray = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"];

		// This shortens the year to two digits
		const shortYear = date.getFullYear().toString().substr(-2);

	// Edit this to change the date format
	// Currently the format is XX/XX/XX
		node.characters = monthArray[date.getMonth()] + "/" + date.getDate() + "/" + shortYear;
	}
}

Gabriel_Leni

Insteresting! Will this give a try…! Thanks a lot @ntfromchicago !


Gabriel_Leni

Brilliant! Will give this a look! 🙂


  • 0 replies
  • February 27, 2022

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings