The carbon trading mechanism is proposed to remit global warming and it can be considered in a microgrid. There is a lack of continuous-time methods in a microgrid, so a continuous-time model is proposed and solved by differential evolution (DE) in this work. This research aims to create effective methods to obtain some useful results in a microgrid. Batteries, microturbines, and the exchange with the main grid are considered. Considering carbon trading, the objective function is the sum of a quadratic function and an absolute value function. In addition, a composite electricity price model has been put forward to conclude the common kinds of electricity prices. DE is utilized to solve the constrained optimization problems (COPs) proposed in this paper. A modified DE is raised in this work, which uses multiple mutation and selection strategies. In the case study, the proposed algorithm is compared with the other seven algorithms and the outperforming one is selected to compare two different types of electricity prices. The results show the proposed algorithm performs best. The Wilcoxon Signed Rank Test is also used to verify its significant superiority. The other result is that time-of-use pricing (ToUP) is economic in the off-peak period while inclining block rates (IBRs) are economic in the peak and shoulder periods. The composite electricity price model can be applied in social production and life. In addition, the proposed algorithm puts forward a new variety of DE and enriches the theory of DE.