When a Pineapple is harvested, it doesn’t get sweeter, only the colour changes.
That means that every single pineapple in the grocery store, local fruit shop or bought from the street is as sweet as it will ever be. So when you buy a pineapple you should eat it as quickly as you can.
There are various reasons for colour difference, but it is mainly based on where the pineapple is grown as well as weather conditions. So a green pineapple can be just as sweet and yummy as a golden yellow pineapple.