The hybrid cloud has attracted more and more attention from various fields by combining the benefits of both private and public clouds. Task scheduling is still a challenging open issue to optimize user satisfaction and resource efficiency for providing services by a hybrid cloud. Thus, in this paper, we focus on the task scheduling problem with deadline and security constraints in hybrid clouds. We formulate the problem into mixed-integer non-linear programming, and propose a polynomial time algorithm by integrating swarm intelligence into the genetic algorithm, which is named SPGA. Specifically, SPGA uses the self and social cognition exploited by particle swarm optimization in the population evolution of GA. In each evolutionary iteration, SPGA performs the mutation operator on an individual with not only another individual, as in GA, but also the individual’s personal best code and the global best code. Extensive experiments are conducted for evaluating the performance of SPGA, and the results show that SPGA achieves up to a 53.2% higher accepted ratio and 37.2% higher resource utilization, on average, compared with 12 other scheduling algorithms.