If you’re going to Joshua Tree from Palm Springs, it’s an hour drive out, and I’d recommend planning at least a 4-hr round trip — with all that driving, you’ll want at least 2 hours in the park, esp. since the interesting sites are spread out, and you’ll be driving from site to site within the park.
Also, you may run into what we did — high winds and a sandstorm that led to one of the major roads being closed, with barricades and cop cars turning us away. Too dangerous to drive!
You can see the sand in these pictures, blowing up. It was all fine — we took maybe another ten minutes going another way. But we were kind of glad that we were in a heavy car and had five adult women weighing it down, because the wind really did shift us around the road a lot!