-1

I would like to convert the human readable date into YYYYMMDD. Just wondering how can I do this. Thanks.

Input Date :-

Sep 30, 2016 11:20:34 AM

Output Date :-

20160930112034 
5 (Friday)
Teja
  • 13,214
  • 36
  • 93
  • 155
  • Do you want to do this with bash? In that case this question is answered here http://stackoverflow.com/questions/6508819/convert-date-formats-in-bash – Linkan Oct 02 '16 at 18:01
  • by unix/linux, do you mean `bash`? – Ayush Oct 02 '16 at 18:01
  • Yes its in bash – Teja Oct 02 '16 at 20:27
  • 2
    Possible duplicate of [How to convert DATE to UNIX TIMESTAMP in shell script on MacOS](http://stackoverflow.com/questions/3817750/how-to-convert-date-to-unix-timestamp-in-shell-script-on-macos) – shellter Oct 03 '16 at 03:07
  • When I searched for `[osx] convert date' there are numerous OSX specific answers close enough to help you solve this problem. Please try searching before posting. Good luck. – shellter Oct 03 '16 at 03:09

2 Answers2

1

This command will have exact output you have posted at Ubuntu 16.04:

$ date -d"Sep 30, 2016 11:20:34 AM" "+%Y%m%d%H%M%S %n%u (%A)"
20160930112034 
5 (Friday) 

According to this question you might need to adjust it for Mac os. Check this command for ex.:

$ date -j -vJulm -v20d -v1999y '+%A'

Here is manual for date command for Mac OS X.

Community
  • 1
  • 1
idobr
  • 1,537
  • 4
  • 15
  • 31
0

Here is a Bash solution:

$ date -d"Sep 30, 2016 11:20:34 AM" "+%Y%m%d - %A"
20160930 - Friday
chenchuk
  • 5,324
  • 4
  • 34
  • 41