Skip to main content

現在時刻

Python

py
t = datetime.datetime.now()  # datetime class

PHP

php
$dt = new DateTime(); // DateTime class

Bash

bash
date

Ruby

rb
t = Time.now  # Time class
rb
t = Time.new  # now でも new でも

PowerShell

powershell
$dt = [DateTime]::Now

単に Get-Date で良いかも

C++

gettimeofday() を使う

cpp
#include <time.h>
#include <sys/time.h>

double gettimeofday_sec()
{
struct timeval tv;
gettimeofday(&tv, NULL);
return tv.tv_sec + (double)tv.tv_usec*1e-6;
}

C#

cs
DateTime.Now

Java

java
long a = System.currentTimeMillis();