How can i keep my beer cold up to 12 hours while hiking ??
If you are in a place that has streams, placing the beer in the water every time you take a break will cool them. Place in a cold/cool body of water about 30 minutes before drinking will also help. If you don't have a body of water, wrap the individual cans/bottles in a wet towel in the shade, preferable where it is windy. Evaporation will cool the beers.
Last option will be to use some form of insulating container, keeping it will shaded in the backpack and add cold water just before drinking.
If you are in the USA look into Pat's Backcountry beer mixtures, that way you just add cold water from a stream/spring to have a cold beer.
(Caveat: I don't drink while hiking)
A group I hiked with once locally used a cooler tube. It appeared to keep everything chilled on a warm-ish day in the Southeastern U.S. There are quite a view vendors of similar products and it appeared to work well with a hiking setup for carrying.
This is just a day hike, not an extended backpacking trip? Then use a good cooler with dry ice.
Elaboration: Dry ice is colder than water ice (-78°C vs 0°C), and thus in a well-insulated cooler should keep anything cold longer. It also has the advantage of sublimating instead of melting, so your load would become progressively lighter. Of course you would probably need to practice a bit to figure out just how much dry ice to use so that you don't wind up with your beer still frozen solid at the end of the day.
OTOH, if it's a day hike, I would leave the drinks & food at the trailhead/camp site. I've had no problem using regular ice for several days of cold food & drink when for instance camping with the horses.
Alternatively, you could get a solar electric cooler for use at the trailhead/camp site.