Hi R.,
Hitting at that age is a way to express theirs feelings. They can't talk, so they use other tools like hitting. The few things you can do is when he hits you or hits someone else, just hold his hands and say: "No hitting, hitting hurts!". If you are showing an anger when you get hit, he might use the hitting to get your attention every time he needs it. Enough that you can give him simple words to express his feelings like: "Oh, you hit me, you must be angry, when we are angry we stomp feet!" Stay calm and keep the words simple. Also, start telling him what to do instead of what not to do like: "I can see you are upset, instead of hitting me give me a hug, that will make you feel better.". Acknowledge his feelings, give him simple words, tell him what to do, stay calm and model a good behaviour for him. Tell him when you are angry and show him how you deal with your anger. And if the hitting happens on a play-date or play-ground just apologize and leave with him imideatly. He will get the message. Time out with hitting doesn't work. The urge to hit is really strong. Say something like: "You hit your friend again, that means you had enough play, we need to go." Take him to the car, stay calm and no more explanations. Be ready to do that anytime even if you just came on the play-ground. Good luck!