I'm trying to get the last image available in an image collection but I can't find any function that works.
I've tried also to sort the collection in the reverse order, but it doesn't work.
here is my code:
var chirps = ee.ImageCollection("UCSB-CHG/CHIRPS/PENTAD");
//get the first image and its date
var firstimg = chirps.limit(1, 'system:time_start').first();
var firstdate = ee.Date(firstimg.get('system:time_start'))
print(firstdate);
//now I try to get the latest...
chirps.sort('system:time_start', false);
var lastimg=chirps.limit(1, 'system:time_start').first();
print(ee.Date(lastimg.get('system:time_start')));
How can I get the last image available and its date in order to know which is the last date available?