Playback sound file on PSTN line

Is it possible to use Asterisk to play a sound file before and after working hours on a PSTN line, and just keep using the phones connected to the PSTN line during work hours?

Yes. Examples of timed dialplans are given in the sample configuration file.

Thank you for the information.

What would be the hardware setup to achieve this? Is it possible to use the Asterisk server in parallel with the PSTN line, so Asterisk plays the sound file before and after working hours, and during the working hours the PSTN line is used? Or should everything be connected to the Asterisk server (PSTN line to FXO port and all analog phones to FXS ports)?

You could parallel wire Asterisk on a simple analogue line, but that would be an overkill application of Asterisk.