import 'dart:html'; void main() { var dt1 = new DateTime.now(); querySelector('#datetext').text = dt1.toString(); querySelector('#year').text = dt1.year.toString(); querySelector('#month').text = dt1.month.toString(); querySelector('#day').text = dt1.day.toString(); }
index.htmlhtml
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>dateTest</title> <script async src="main.dart" type="application/dart"></script> </head> <body> <div id="datetext"></div> <div id="year"></div> <div id="month"></div> <div id="day"></div> </body> </html>
結果:java