The resulting $t$ statistic from a t-test follows a t-distribution with parameter $k = $ freedom-degrees. For us to compute the probability of $t$ to occur, we use the cumulative distribution function of the t-distribution ($CDF_t$).
For a left-sided test, this is equal to finding the probability on the y-axis of the CDF, which intersects with the given $t$ value.
For a right-sided test, this is equal to 1 - the left-sided p-value.
What about the two-sided test? I am not sure how this p-value is computed using the CDF.
So far I have only seen this method: (from https://stackoverflow.com/questions/45045802/how-to-do-a-one-tail-pvalue-calculate-in-python)
$ p = CDF_t(t , df) * 2$
i.e. the left-sided p-value multiplied by two.. which strikes me as odd, as the p-value ranges from 0 to 1, this equation generates a p-value in the domain [0-2].