Closed Thread
Thread Tools Search this Thread
Unread 6th Jul 2013, 02:25 AM   #1
Warrior Member
 
Join Date: 2012
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default
PHP Date function help required
Share on: 
fb share twitter share gplus share more share

I am getting current date in php using date function but what I want is date before 15 days. I mean if today is 15th jan then i want it 1st Jan as a date.

Thanks
wizwebtechno is offline  
Unread 6th Jul 2013, 02:43 AM   #2
Active Warrior
 
bugtrack's Avatar
 
Join Date: 2012
Location: United Kingdom
Posts: 60
Thanks: 0
Thanked 5 Times in 5 Posts
Default
Re: PHP Date function help required
Share on: 
fb share twitter share gplus share more share

You can use strtotime function for that here is an example for what you are looking for

PHP Code:
date('Y-m-d', strtotime('-7 days')) 
Hope it wills olve your problem
bugtrack is offline  
Unread 6th Jul 2013, 01:55 PM   #3
Active Warrior
War Room Member
 
Paul Moss's Avatar
 
Join Date: 2013
Location: Florida
Posts: 49
Thanks: 0
Thanked 4 Times in 4 Posts
Default
Re: PHP Date function help required
Share on: 
fb share twitter share gplus share more share

Or you can use if you are using greater than php 5.3


$date = new DateTime(date("Y-m-d"));
$date->modify('-15 day');
echo $date->format('Y-m-d');
Paul Moss is offline  
Unread 7th Jul 2013, 02:28 PM   #4
HyperActive Warrior
 
Join Date: 2010
Posts: 267
Thanks: 5
Thanked 6 Times in 6 Posts
Default
Re: PHP Date function help required
Share on: 
fb share twitter share gplus share more share

Hope this helps

<?php
echo date("jS F", strtotime('+15 days'));
?>

Thanks & Regards,
Reach us at dukeduke600@gmail.com.
Web Design| Logo Design | Banner Design | Web Development | Mobile Applications [iPhone/iPad/Android/Windows Phone]
weaveronline is offline  
Unread 12th Jul 2013, 01:14 AM   #5
Mobitech
 
octalsoftware's Avatar
 
Join Date: 2012
Posts: 51
Thanks: 6
Thanked 2 Times in 2 Posts
Default
Re: PHP Date function help required
Share on: 
fb share twitter share gplus share more share

<?php
echo date("Y/m/d") . "<br>";
echo date("Y.m.d") . "<br>";
echo date("Y-m-d");
?>

output::
2013/07/12
2013.07.12
2013-07-12

octalsoftware is offline  
Closed Thread


Bookmarks

Tags
date, function, php, required

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 12:01 PM.