0

I want to convert specific/Input date to different timezone. I have tried below code.

dateYMD="2019/2/28 12:23:11.46"

timesydney=$(TZ=Australia/Sydney date -d "$dateYMD" +%s)

But above code give me a below error....

date: Not a recognized flag: d

Usage: date [-u] [+"Field Descriptors"]

Mehul
  • 13
  • 4
  • What `unix` are you running on? The `-d` option is for GNU date, that is primarily installed on Linux. Are you running openbsd? Macos? I think you are [on AIX](https://www.ibm.com/support/knowledgecenter/en/ssw_aix_71/d_commands/date.html). Please specify the platform in your question. I believe you need to go with compiling and installing GNU date or [dateutils](http://www.fresse.org/dateutils/). Or write your own small C program to do the conversion. – KamilCuk Jan 17 '20 at 10:57
  • I am working on Unix KSH script. – Mehul Jan 17 '20 at 11:50
  • "Ksh" is a shell implementation. You can run ksh on linux. You can run ksh on openbsd. Linux, openbsd and AIX are all descendants of unix. I am asking about the operating system. I am asking specifically about what `date` implementation do you have. – KamilCuk Jan 17 '20 at 11:52
  • I am a beginners. I am working on Win 10 and I just want to update Timezone of provided date. I am working on KSH shell. – Mehul Jan 20 '20 at 08:03
  • I just want to change timezone of date entered by use (Like dateYMD="2019/2/28 12:23:11.46") to different timezone. – Mehul Jan 20 '20 at 08:04
  • `I am working on Win 10` - then install bash or cygwin and with some luck your code should work. – KamilCuk Jan 20 '20 at 12:00

0 Answers0