I try to get all acquisition dates of my ImageCollection in Google Earth Engine Code Editor.

var begin = ee.Date.fromYMD(2017,1,1,'Europe/Berlin');
var end = ee.Date.fromYMD(2018,1,1,'Europe/Berlin');
var orbnr = ee.Number(15);

//Load S1 ImageCollection and filter by Location and Date
var s1_collection = ee.ImageCollection('COPERNICUS/S1_GRD')

//Filter S1 IC by OrbitNr.
var s1_collection_f = s1_collection

//Get Dates with ee.image.date() while mapping over the ImageCollection
var get_date = function(image) {
  var dates = ee.List(image.date())
  return s1_dates.add(dates)};


Last 4 lines of code seems to be wrong. Do i write the function the right way? First time i try to write my own function in javascript.... Do i have to assign a empty list bevore i call s1_dates.add(dates) ? When how can i assign a empty list. Or is it better to use a 1D array instead?

  • Thanks to Noel Gorelick for his useful answer. How can we export the "dates" list to a CSV file? Thanks
    – Omid Zandi
    Commented May 5, 2022 at 11:58

2 Answers 2


The s1_dates variable isn't defined, but even if it was, you can't modify global variables inside mapped functions. You probably just want this:

dates = s1_collection_f.aggregate_array("system:time_start")

which is equivalent to this:

var dates = s1_collection
    .reduceColumns(ee.Reducer.toList(), ["system:time_start"])

But, looking ahead, you probably didn't really want 361,000 separate acquisition times. You probably want at least distinct times, and more likely, distinct days (Y-M-D), in which case you need to convert the date somewhere along the way (it's in milliseconds). The easiest way to do that is to map a function over the images, returning a feature for each image containing just the formatted date. Then you can use distinct().

var dates = s1_collection_f
    .map(function(image) {
      return ee.Feature(null, {'date': image.date().format('YYYY-MM-dd')})

if the name of your collection is s1_collection_f:

var dates = s1_collection_f.aggregate_array('system:time_start');
dates = dates.map(function(x){return ee.Date(x)})

output is something like this:

A list (#number of elemets)
Date (2021-01-06 18:19:55)
Date (2021-01-30 18:19:54)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.