Natural gas, hydrogen, methane, or their mixture play important roles in the energy systems, and the coordinated optimal scheduling for the integrated energy systems are requisite in consideration of complicated system characteristics. This paper focuses on mixed-integer second-order cone programming-based optimal scheduling for the electric grids with gas flow dynamics in consideration of AC power flow, unit commitment, and line switching. For the gas grids, differential continuity equations and differential momentum equations, representing gas flow dynamics, are discretized to a group of algebraic equations with the implicit trapezoidal rules. In the algebraic equations, nonconvex bilinear terms with integer variables, representing gas flow directions, are transformed into linear inequality constraints with McCormick envelopes, and quadratic terms are relaxed by the second-order cone (SOC) approach. For the electric grids, SOC relaxation-based AC power flow models are employed, and the line switching problem is modeled by the improved SOC relaxation approach with McCormick envelopes. The entire problem is established as a mixed-integer second-order cone programming model, and the impacts of gas flow dynamics on the feasible region compared to the steady-state region are discussed.