View Problem

Display the current date and time

Create a Date object representing the current date and time. Print it out.
If you can also do this without creating a Date object you can show that too.
DiskEdit
clojure
(import 'java.util.Date)

(println (str (Date.)))
ExpandDiskEdit
cpp Qt 4.x
QDate now = QDate::currentData();
qDebug() << now.toString();
ExpandDiskEdit
cpp
time_t date = time(0);
cout << ctime(&date);
DiskEdit
csharp
// Creating a variable first:
DateTime now = DateTime.Now;
Console.WriteLine(now);

// Without creating a variable:
Console.WriteLine(DateTime.Now);
DiskEdit
erlang
io:format("~p~n", [calendar:local_time()])
ExpandDiskEdit
fantom
echo(DateTime.now)
DiskEdit
fsharp
printfn "%A" System.DateTime.Now
ExpandDiskEdit
go 1+
fmt.Println(time.Now())
DiskEdit
groovy
println new Date()
DiskEdit
haskell
import System.Time

main = do ct <- getClockTime
print ct
DiskEdit
haskell
import Data.Time

main = do zt <- getZonedTime
print zt
DiskEdit
haskell
import System.Time

main = print =<< getClockTime
DiskEdit
java
import java.util.Date;

public class SolutionXX {
public static void main(String[] args) {
Date now = new Date();
System.out.println(now.toString());
}
}
DiskEdit
ocaml
Unix.localtime (Unix.gettimeofday ())
DiskEdit
perl
use Class::Date;
my $date = Class::Date->now();
print $date->string()."\n";

print localtime()."\n";
DiskEdit
perl
use Time::Piece ();

# Date object
my $date = Time::Piece::localtime;
print "$date\n";
# no object
print scalar(localtime),"\n";
ExpandDiskEdit
php
echo date('r') . "\n";
$d = new DateTime();
echo $d->format('r') . "\n";
DiskEdit
python
from datetime import datetime
print datetime.utcnow()
DiskEdit
ruby
puts DateTime.now
ExpandDiskEdit
scala
println(new java.util.Date)

Submit a new solution for clojure, cpp, csharp, erlang ...