This language bar is your friend. Select your favorite languages!

Idiom #61 Get current date

Assign to variable d the current date/time value, in the most standard type.

import java.time.Instant;
Instant d = Instant.now();
#include <time.h>
time_t d=time(0);
DateTime d = DateTime.Now;
import std.datetime;
auto d = Clock.currTime;
var d = new DateTime.now();
d = :calendar.local_time
D = calendar:local_time().
import "time"
var d time.Time = time.Now()
d <- System.Posix.Time.epochTime
var d = Date.now();
var d = new Date();
date = os.date()
time = os.time()
$d = time();
var
  _d: TDateTime;
begin
  _d := Now;
end.
$d = time;
import datetime
d = datetime.datetime.now()
d = Time.now
extern crate time;
let d = time::now();

Do you know the best way to do this in your language ?
New implementation...

Idiom created by

programming-idioms.org

Related idioms