ee.Date

  • The ee.Date() constructor creates a new Date object.

  • The ee.Date() constructor can accept various input types for the date argument, including numbers (milliseconds since epoch), ISO Date strings, JavaScript Dates, and ComputedObjects.

  • An optional timezone string can be provided as the second argument when the date is given as a string.

Constructs a new Date object.
Usage Returns
ee.Date(date, tz ) Date
Argument Type Details
date
ComputedObject|Date|Number|String The date to convert, one of: a number (number of milliseconds since the epoch), an ISO Date string, a JavaScript Date or a ComputedObject.
tz
String, optional An optional timezone only to be used with a string date.

Examples

Code Editor (JavaScript)

 // Numeric inputs are interpreted as milliseconds from Unix epoch. 
 print 
 ( 
 ee 
 . 
 Date 
 ( 
 0 
 )); 
  
 // Date (1970-01-01 00:00:00) 
 // Scale factors can make numerical inputs more readable (e.g. 60 seconds). 
 print 
 ( 
 ee 
 . 
 Date 
 ( 
 60 
  
 * 
  
 1000 
 )); 
  
 // Date (1970-01-01 00:01:00) 
 // ISO 8601 date string input examples. 
 print 
 ( 
 ee 
 . 
 Date 
 ( 
 '2020' 
 )); 
  
 // Date (2020-01-01 00:00:00) 
 print 
 ( 
 ee 
 . 
 Date 
 ( 
 '2017-6-24' 
 )); 
  
 // Date (2017-06-24 00:00:00) 
 print 
 ( 
 ee 
 . 
 Date 
 ( 
 '2017-06-24' 
 )); 
  
 // Date (2017-06-24 00:00:00) 
 print 
 ( 
 ee 
 . 
 Date 
 ( 
 '2017-6-24T00:14:46' 
 )); 
  
 // Date (2017-06-24 00:14:46) 
 print 
 ( 
 ee 
 . 
 Date 
 ( 
 '2017-06-24T23:59:59' 
 )); 
  
 // Date (2017-06-24 23:59:59) 
 // With an optional time zone. 
 print 
 ( 
 ee 
 . 
 Date 
 ( 
 '2020' 
 , 
  
 'US/Mountain' 
 )); 
  
 // Date (2020-01-01T07:00:00) 
 // Convert JavaScript now to Earth Engine Date 
 print 
 ( 
 ee 
 . 
 Date 
 ( 
 Date 
 . 
 now 
 ())); 

Python setup

See the Python Environment page for information on the Python API and using geemap for interactive development.

 import 
  
 ee 
 import 
  
 geemap.core 
  
 as 
  
 geemap 

Colab (Python)

 from 
  
 datetime 
  
 import 
 datetime 
 # Numeric inputs are interpreted as milliseconds from Unix epoch. 
 display 
 ( 
 ee 
 . 
 Date 
 ( 
 0 
 ) 
 . 
 format 
 ()) 
 # 1970-01-01T00:00:00 
 # Scale factors can make numerical inputs more readable (e.g. 60 seconds). 
 display 
 ( 
 ee 
 . 
 Date 
 ( 
 60 
 * 
 1000 
 ) 
 . 
 format 
 ()) 
 # 1970-01-01T00:01:00 
 # ISO 8601 date string input examples. 
 display 
 ( 
 ee 
 . 
 Date 
 ( 
 '2020' 
 ) 
 . 
 format 
 ()) 
 # 2020-01-01T00:00:00 
 display 
 ( 
 ee 
 . 
 Date 
 ( 
 '2017-6-24' 
 ) 
 . 
 format 
 ()) 
 # 2017-06-24T00:00:00 
 display 
 ( 
 ee 
 . 
 Date 
 ( 
 '2017-06-24' 
 ) 
 . 
 format 
 ()) 
 # 2017-06-24T00:00:00 
 display 
 ( 
 ee 
 . 
 Date 
 ( 
 '2017-6-24T00:14:46' 
 ) 
 . 
 format 
 ()) 
 # 2017-06-24T00:14:46 
 display 
 ( 
 ee 
 . 
 Date 
 ( 
 '2017-06-24T23:59:59' 
 ) 
 . 
 format 
 ()) 
 # 2017-06-24T23:59:59 
 # With an optional time zone. 
 display 
 ( 
 ee 
 . 
 Date 
 ( 
 '2020' 
 , 
 'US/Mountain' 
 ) 
 . 
 format 
 ()) 
 # 2020-01-01T07:00:00 
 # Convert Python datetime.now() to Earth Engine Date 
 display 
 ( 
 ee 
 . 
 Date 
 ( 
 datetime 
 . 
 now 
 ()) 
 . 
 format 
 ()) 
Design a Mobile Site
View Site in Mobile | Classic
Share by: