'How can I get this timer for my progress bar?

I'm currently learning how to create progress bars but Ive run into a problem. Im not sure how I can reference the running timer in my CraftCopperBar script for my update. Or if i have the wrong idea please correct me.

public IEnumerator CraftCopperBar()
{
    while (copper >= copperBarValue)
    {
        button.SetActive(false);
        copper -= copperBarValue;
        yield return new WaitForSeconds(5f);
        copperBar += 1 * multiplier;

        if (copper < copperBarValue)
        {
            button.SetActive(true);
            break;
        }
    }

public void Update()
progressBar.fillAmount = (float)(x / 5f);


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source