Get current date time in the format of YYYY/MM/DD hh:mm:ss

Output

2019/12/09 07:05:25

Programming code example

JavaScript

Preparation
npm install -g strftime;
Programming code
const strftime=require('strftime');
console.log(strftime("%Y/%m/%d %H:%M:%S"));

Perl

use POSIX qw(strftime);
print(strftime("%Y/%m/%d %H:%M:%S", localtime())."\n");

PHP

<?php
date_default_timezone_set('Asia/Tokyo');
echo date('Y/m/d H:i:s');

Python

from datetime import datetime
print( datetime.now().strftime("%Y/%m/%d %H:%M:%S") )

Ruby

puts Time.now.strftime("%Y/%m/%d %H:%M:%S")

Rust

Corgo.toml

[package]
name = "date_time"
version = "0.0.1"

[dependencies]
chrono = "*"

[[bin]]
name = "date_time"
path = "date_time.rs"
Programming code
extern crate chrono;
use chrono::{Local, DateTime};

fn main() {
  let now: DateTime<Local> = Local::now();
  println!("{}", now.format("%Y/%m/%d %H:%M:%S"))
}

Shell

DATE=`date '+%Y/%m/%d %H:%M:%S'`;
echo $DATE;