...
Both can be done with the Calculate Days Elapsed for Traffic Light Post Function which initialises the information required for tracking the day elapsed.
Prerequisite
Besides a Traffic Light custom field, there should also be a configuration to define the traffic light mappings.
Otherwise, refer Refer to steps here to create a Traffic light custom field, and/or configure the Days Mapping.
Adding the Post Function
For the basics on setting up a workflow, please refer to Jira's documentation on configuring workflows
...