Many companies pays dividend to stock owners.

Example: IBM pays dividend to registered stock owners. Owning the stock on dd:mm:yyyy hh:mm:ss will entitle you to dividend. 

**Question:** Is it possible to buy a stock and own it for a short period of time (minutes or hours) to get paid dividend? 
If yes: 1. is there any cons to this strategy? 2. How to know when to own a stock?

I've been thinking about it, and so far it looks like a "free lunch".