In C:Got it? Good.#include <stdio.h> #include <time.h> #define SIZE 0x100 int main () { time_t t; char buffer[SIZE]; struct tm ltime; t = time (0); localtime_r (& t, & ltime); strftime (buffer, SIZE, "%Y-%m-%d", & ltime); printf ("%s\n", buffer); return 0; }In Bourne-derived shell:#!/bin/sh iso8601=`date +%Y-%m-%d` echo $iso8601In Perl:#!/usr/bin/perl use POSIX qw/strftime/; my $date = strftime "%Y-%m-%d", localtime; print "$date\n";In Ruby:#!/usr/bin/ruby iso8601 = Time.now.strftime("%Y-%m-%d") p iso8601In PHP:<?php $iso8601=date('Y-m-d'); print $iso8601."\n";In Python:#!/usr/bin/python from datetime import date iso8601=date.today().isoformat() print iso8601
2013-02-27
ISO-8601
Posted by
Ax0n
blog comments powered by Disqus
Subscribe to:
Post Comments (Atom)