Last active
January 1, 2016 08:49
-
-
Save asserchiu/8121275 to your computer and use it in GitHub Desktop.
UNIX date time format conversion using `sed`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat dm.test | |
25/12/2013,20:00:00,asdf,qwer,zxcv | |
$ sed -n -e "s_\(..\)/\(..\)/\(....\),_\3-\2-\1T_p" dm.test | |
2013-12-25T20:00:00,asdf,qwer,zxcv | |
$ date --universal --rfc-3339 ns|sed -ne "s_^\(....-..-..\)\ \(..:..:..\....\).*_\1T\2Z_p" | |
2013-11-15T19:39:42.146Z | |
$ alias date.toISOString='date --universal --rfc-3339 ns|sed -ne "s_^\(....-..-..\)\ \(..:..:..\....\).*_\1T\2Z_p"' | |
$ date.toISOString | |
2013-12-03T11:07:09.591Z |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment