Reverse strtotime()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
thiscatis
Forum Contributor
Posts: 434
Joined: Thu Jul 20, 2006 11:00 am

Reverse strtotime()

Post by thiscatis »

A quick question,

i'm using this code:

Code: Select all

$todays_date = date("Y-m-d"); 
$today = strtotime($todays_date);
But how do I reverse this.
Go from $today to $todays_date
User avatar
bokehman
Forum Regular
Posts: 509
Joined: Wed May 11, 2005 2:33 am
Location: Alicante (Spain)

Post by bokehman »

Code: Select all

date("Y-m-d", $today);
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I'm really confused on what you've posted. I don't know why but I am, so lets go through this quick.

You have a date call, as a string and convert this to a timestamp.
Now, you want to have a timestamp and convert it to a date string?

Why not just do

Code: Select all

date('m-d-Y', time()); 

//or if you want to use any timestamp

date('m-d-Y', strtotime('+5 days'));
thiscatis
Forum Contributor
Posts: 434
Joined: Thu Jul 20, 2006 11:00 am

Post by thiscatis »

That was just an example.

What I want to do:
Put all my data in a database with a column active_date set to a prefered date,

The script then first gets today's date, queries the database for all the timestamps in the rows,
compares the results with todays date, only displays the results where today's date > active_date and displays
the the date in US Format YYYY-MM-DD

I hope that makes sense ;)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Uh... let the database do all that work.
Post Reply