35.170.54.171 |    

Navigation

Google Advertisement

format
  1. #!/bin/bash
  2.  
  3.  
  4. function format() {
  5.  
  6. [ "$#" -ne 4 ] && exit 1
  7. if [ "$1" = "date" ]; then
  8. 	printf "%04d-%02d-%02d\n" "$2" "$3" "$4"
  9. else
  10. 	printf "%02d:%02d:%02d\n" "$2" "$3" "$4"
  11. fi
  12.  
  13. }
  14.  
  15. #----- format year   mon  day
  16. format "date" "2005" "9" "22"
  17.  
  18. #----- format hour min sec
  19. format "time" "2" "9" "22"
Parsed in 0.002 seconds at 159.23 KB/s

Search
 
Full text search by name and content of a snippet.

User online
There are 5 users online.

Tags Cloud

Latest snippets
str2seconds
(Bash::Function)
is_integer
(Bash::Function)
file_rotate
(Bash::Function)
confirm
(Bash::Function)
is_workingtime
(Bash::Function)
last day of last month
(Bash::Snippets)
crypt_apr1_md5
(PHP::Function)
crypt_apr1_md5
(Perl::Function)
transparent
(CSS)
rfc2822Toiso8601
(PHP::Function)