Jump to content

Archived

This topic is now archived and is closed to further replies.

emilyfrazier

mySQL date mktime problems!!!

Recommended Posts

Hi all,

I am still fairly new to PHP and mySQL. I have read all the tutorials on dates, yet I'm still not seeing the light today.

So I have a field in my database called 'date_joined' that holds a timestamp when a users signs up for membership. I need to make a report that tells me all the memberships that will expire within the next 30 days (memberships are for 1 year).

Is there a way to take my field and use mktime to add 1 year to it? I assume it's possible through a function that breaks up the date and then subs them in to a mktime string, but I was wondering if there is an easier way around it?

I would really appreciate any help in advance.

Thanks so much,
eef

Share this post


Link to post
Share on other sites
is it a `datetime` timestamp ?

[code]
date('Y-m-d H:i:s', time() + (365 * 24 *60 * 60));
[/code]

Share this post


Link to post
Share on other sites
Thanks so much for the help...it doesn't work quite right. It is taking today's date if I use this code. I tried:

$yr = date('Y-m-d H:i:s', time($data['date_joined']) + (365 * 24 *60 * 60));


And it gives me today's date a year from now...I need it to take a year from now from the 'date_joined' field...thanks again

eef

Share this post


Link to post
Share on other sites
I got it working using this:[code] $datemysqlyr = date ( "Y m d H:i:s" , strtotime ( $data [ 'date_joined' ]) 
+ (365 * 24 *60 * 60));
[/code]

Thanks very much for your help!!

eef

Share this post


Link to post
Share on other sites
You can also use:
[code]<?php $datemysqlyr = date('Y m d H:i:s',strottime($data [ 'date_joined' ] . ' + 1 year')); ?>[/code]

Ken

Share this post


Link to post
Share on other sites

×

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.