Age Calculator Brick Workaround

Abby Updated by Abby

We currently have an age calculator brick, however, it's made for V2, if you're using V3 you can make it work with the following workaround:

Import the brick

Open brick and go to the Javascript block

Remove the current code and add the following

let landbotScope = this;

function getAge(datepicker)
{var today = new Date();Β var birthDate = new Date(datepicker); var age = today.getFullYear() - birthDate.getFullYear();var m = today.getMonth() -birthDate.getMonth();Β if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())) {Β age--;}Β Β 

landbotScope.setCustomData({age: age})}getAge("@{datepicker}");

That's it!

How did we do?

How to link your Calendly account and prepare your agenda

Get a timestamp according to a defined TimeZone

Contact