Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

AWS SDK for PHP rejects requests: the signature is from the future

ErrorSignature not yet current: {date} is still later than {date}

Short answer

AWS compares the timestamp in your signed request with its own clock. 'Signature not yet current' means your request claims a time later than AWS expects, so the server's clock runs ahead. Check the clock and NTP status on the machine running PHP, turn time sync on, and make sure any hand-written signing code uses UTC.

  • Applies to PHP 8.3, aws-sdk-php 3, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Compare the machine's idea of UTC with the real time. Run this on the host or container that runs PHP, not on your laptop.

    date -u
    timedatectl status
  2. 2Match what you see, then jump to its fix

    1. 1The first date in the message is later than the second; timedatectl shows 'System clock synchronized: no'The server clock runs ahead of real timeFix
    2. 2Only your own signing function fails; SDK calls from the same host workHand-written signing code builds the timestamp in local timeFix

What does the error look like?

  • Signature not yet current: {date} is still later than {date}

Cause 1 of 2

The server clock runs ahead of real time

1Check

timedatectl prints the synchronisation state. If it says no, the clock is not being corrected.

timedatectl status
timedatectl timesync-status

2Fix

Turn on network time synchronisation. The command enables and starts the first existing time sync service on the machine.

sudo timedatectl set-ntp true

3Verify

The status shows the clock as synchronized, and a new SDK call no longer fails.

timedatectl status | grep -i synchronized
date -u

Confirmed by freedesktop.org

Did this fix it?

Cause 2 of 2

Hand-written signing code builds the timestamp in local time

1Check

AWS requires the timestamp in UTC in the form YYYYMMDDTHHMMSSZ. Search your code for date() or DateTime without a UTC timezone.

grep -rn "x-amz-date\|X-Amz-Date" src/ app/

2Fix

Generate the stamp in UTC. Better, let the SDK sign the request instead of writing the signature yourself.

<?php
$now = new DateTimeImmutable('now', new DateTimeZone('UTC'));
$amzDate = $now->format('Ymd\THis\Z');

3Verify

The x-amz-date value ends in Z and matches the output of date -u.

<?php
echo (new DateTimeImmutable('now', new DateTimeZone('UTC')))->format('Ymd\THis\Z');

Confirmed by docs.aws.amazon.com

Did this fix it?

How do I stop it coming back?

  • Keep time synchronisation on for every server and container host that signs AWS requests.
  • Use the AWS SDK for PHP to sign requests instead of building signatures by hand.
  • Add a clock-drift check to your monitoring so a drifting host is found before API calls fail.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

CodeIgniter 4 cannot write its cache files

CodeIgniter\Cache\Exceptions\CacheException: Cache unable to write to /var/www/app/writable/cache/

CodeIgniter 4's file cache needs a cache directory that the web server can really write to.

2 causes, each with a fix

Back end

CodeIgniter 3 loads the model but the property is undefined

The model name you are loading is the name of a resource that is already being used: user

CodeIgniter 3 expects a model file named like its class, with the first letter capitalised, for example User_model.php holding class User_model.

2 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.