Programming is a creative task, it cannot be strictly estimated. Somebody mentioned Evidence-Based Scheduling, and it's the best way to estimate ("doing X is similar to Y, and it took Z hours, so it will be unspecified amount of time, but probably around Z hours"
But maybe significantly longer. Programming is a little special, because if you done it before, then doing it again takes no time, you just reuse the code from last time. So you're always doing something you never done before, or at least in a different context.