Melatonin is a sleep hormone that our bodies produce naturally at night time. It basically indicates that it is nighttime and makes it easier to fall asleep and stay asleep. Gwern has a page with lots of information about it.
Here, I will document how I used melatonin to reduce jet lag during a recent conference trip to Los Angeles (which is 9 time zones away from my home in Denmark), both for my own future reference, and to the benefit of anyone who might find it useful.
I don't claim that this is the ultimate solution, but was fully functional all day already the day after arriving both ways. At the same time, other people mentioned being affected by jet lag multiple days after arrival.
The first thing I did was taking melatonin during what is the night time in the destination time zone already the day before i spent my first night there. For instance, on the day that I traveled to LA, I started taking melatonin at 9 am Central European Time (CET) because that would be 12 am Pacific Time (PT) which is when I wanted to go to bed. I did this in order to start getting my body used to the new sleep schedule ahead of time, since melatonin basically works as an indicator of night time for the body.
Concretely I took 0.2 mg melatonin every 2 hours from 9 am to 15 pm CET in order to cover what corresponds to a typical 8 hour sleep.
Just sleep normally according to the new time zone. Use time released melatonin to make sure that you sleep sound all night. You need time released pills for this, because otherwise the effect will wear off within a couple of hours. If this happens when you travel west you'll wake up way too early and not be able to go to sleep again.
I keep using time released melatonin every night until I am completely sure that I will be able to sleep through the night without it, which usually takes about a week. There is no real disadvantage to taking it even if it isn't needed, so I'd rather use it for too long than wake up in the middle of the night.
I don't think that dosages matter a lot. The pills with the lowest doses that you can buy at pharmacies in the US usually contains an order of magnitude more melatonin than you need, and you don't have to be concerned about taking too much.
The easiest way to acquire melatonin is to buy it where you can get it over the counter, like the US. In Denmark, melatonin is a prescription medicine, but it is still possible and fairly easy to order from another country in the EU where it isn't, so I usually get mine from www.melatonine.nl.