Date and Time Formatter Tool

How to Use This Tool

This tool formats the current date and time based on your selected formats.

Tool Details

  • Date Format: Select the desired date format from the dropdown.
  • Time Format: Select the desired time format from the dropdown.
  • Format: Click this button to format the current date and time.
  • Result: Displays the formatted date and time combined.

Code Snippets for Date Formatting

SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String formattedDateTime = sdf.format(new Date());
            
echo date("Y-m-d H:i:s");
            
const date = new Date();
const formattedDateTime = date.toISOString().replace('T', ' ').substr(0, 19);
            
format(Sys.time(), "%Y-%m-%d %H:%M:%S")
            
#include <time.h>
#include <stdio.h>

time_t now;
struct tm *local_time;
char buffer[80];

time(&now);
local_time = localtime(&now);
strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", local_time);
printf("%s\n", buffer);
            
#include <iostream>
#include <ctime>
#include <iomanip>

std::time_t t = std::time(nullptr);
std::cout << std::put_time(std::localtime(&t), "%Y-%m-%d %H:%M:%S") << std::endl;
            
from datetime import datetime

current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
print(current_time)
            
require 'time'

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

import (
    "fmt"
    "time"
)

func main() {
    currentTime := time.Now()
    fmt.Println(currentTime.Format("2006-01-02 15:04:05"))
}
            

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!