Martinsburg is located at 39°27'21" North, 77°57'50" West (39.456111, -77.963889).
According to the United States Census Bureau, the city has a total area of 5.05 mi2 (13.07 km2). 5.03 mi2 (13.02 km2) of it is land and 0.02 mi2 (0.04 km2) of it is covered by water. The total area is 0.33% water.
Martinsburg is located in the Eastern Standard Time (EST) timezone, GMT-05:00. It observes Daylight Saving Time (DST).