Access time range in Script


I’m trying to get a percentage based on the number of seconds in a time range.
I can currently do it if I hardcode the number of seconds in the script field, as follows:
(_value / 31557600) * 100
The problem is that if the time range of the dashboard is changed, the % still refers to the hardcoded figure.
Grafana passes a filter with the start/end times in epoch_millis.
Is it possible to access those two timestamps as a variable in the script?