The thirty-seven-star United States flag became the official national flag on July 4, 1867, and remained in use for ten years. The three presidents who served under this flag were Andrew Johnson from 1865 to 1869, Ulysses S. Grant from 1869 to 1877, and Rutherford B. Hayes from 1877 to 1881.