I'd like to color labels based on the difference between the current time and a datetime field in a CSV layer in a JSAPI application. Ideally, it would be on a continuous scale (something like recent=green and oldest=red), but if need be, I could divide the scale into a few discrete stops. I don't see a way to use visual variables with labels, which was my first thought. My second thought was to create a separate layer just for the labels, but while I could use a visual variable to control the color, I couldn't get the text to reflect a field in the data.
I then resorted to discrete stops, using several labelClasses with where clauses, but I'm having trouble figuring out how to work with timestamps within those where clauses (how to get the current time, how to convert a field of my csv to date to compare it against, how to then subtract the two and compare the difference to some threshold)
I think you're on the right track with the multiple LabelClass and where clauses. This is the approach we use in this sample: Add multiple label classes to a layer