I need to send a date (formatted like 2011-06-07T05:34:28+0200) in a POST HTTP Request. In order for this to work, I need to change the '+' or '-' of the timezone by '%2B' or '%2D' respectively. What is the most efficient way to do this in a bash / sed one liner?
The following only change the '+' as there is a single '+' (the one in the timezone).
d1=$(date +%Y-%m-%dT%H:%M:%S%z) // -> 2011-06-07T05:34:28+0200
d2=$(echo $d1 | sed -e 's/+/%2B/')
How to change the '+' or '-' character only within the timezone in a single command?