[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 363
  • Last Modified:

How to change date format for a date variable?

Experts,

I am using PHP 5.0.

Example URL: test.com?date=08-13-2014

How can I change the format of $_GET['date'] to YYYY-MM-DD?

Using

$date = date('Y-m-d', strtotime($_GET['date']));
echo $date;

Always yields 1969-12-31

I feel like I am in the twilight zone here.

Please help.
0
evibesmusic
Asked:
evibesmusic
1 Solution
 
GaryCommented:
$date = date('Y-m-d', strtotime(str_replace('-', '/', $_GET['date'])));
echo $date;

Open in new window

0
 
evibesmusicAuthor Commented:
Thanks.
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now