Jump to content

Append Date to Filename

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
Chan

Chan

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 204 posts
How can I append the date/time to a filename? For instance, if I have:


$filename = "/results-";


but would like it to be results-8-03-2006-3-52

How could I do that?

#2
Crane

Crane

    Programming Expert

  • Members
  • PipPipPipPipPipPip
  • 398 posts
Here you go:


// Get our date

$date = date('d-m-y-h-i');


// Set a filename

$filename="/results-" . $date;



#3
Blaze

Blaze

    Programmer

  • Members
  • PipPipPipPip
  • 117 posts
You can change the format of the date() function as well chan. Check out php.net and search for the date function.