Skip to content

Latest commit

 

History

History
26 lines (19 loc) · 589 Bytes

ex3-1.md

File metadata and controls

26 lines (19 loc) · 589 Bytes

3.1 Declaring Functions

Example Code:

The getCurrentDateTime() function gets the current date and time in London and prints it to the console.

The DateTime.now() method returns the current date and time in the local time zone. In this case, the local time zone is London.

The print() function prints the value of the timeLondon variable to the console.

void main() {
  getCurrentDateTime();
}

void getCurrentDateTime() {
  var timeLondon  = DateTime.now();
  print('London:    $timeLondon');
}

Example Output:

London:     2023-08-31 09:42:34.310135