The ex-dividend date is the trading day on and after which a new buyer of the stock is not entitled to any dividends. Most traders say that a stock has gone ex-dividend when this happens.
Traditionally, the ex-dividend date is set a day before the record date when a company evaluates its records for existing shareholders. If a trader buys a stock that has gone ex-dividend from a seller, the one who'll get dividends is the seller.