Jump to content

[SOLVED] Date times....


phpSensei

Recommended Posts

I have a little question...

 

Can I use the SELECT statement, and Display all my data from a certain table depending on the date?

 

If the date is newer then it will show that id, within the table?

 

Any of this possible?

 

I was thinking of this

 


<?php

$sql="SELECT * FROM table_1 ORDER BY date ASC";
$result=mysql_query($sql);
$row=mysql_fetch_array($result);
?>

Link to comment
Share on other sites

Exactly how you resolve it depends on what format you've used for 'date' in your database. The date() function along with the strtotime() or mktime() functions ought to be able to handle most of what you need.

 

list($y,$m,$d) = explode("-",date("Y-m-d"));// today
$month_ago = date("Y-m-d", mktime(0,0,0,$m-1,$d,$y));

Link to comment
Share on other sites

Exactly how you resolve it depends on what format you've used for 'date' in your database. The date() function along with the strtotime() or mktime() functions ought to be able to handle most of what you need.

 

list($y,$m,$d) = explode("-",date("Y-m-d"));// today
$month_ago = date("Y-m-d", mktime(0,0,0,$m-1,$d,$y));

 

Thankyou so much, My forum is done with everything.

 

This was the only thing left.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.