They can work as nouns or adverbs.
For example: "yesterday was a great day"; here, "yesterday" works as a noun. But in "I will do that tomorrow", "tomorrow" works as an adverb.
- "Yesterday was a great day"; here, yesterday works as a noun.
- "I will do that tomorrow"; here, tomorrow works as an adverb.