Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Variable into datetime Format

Posted on 2013-06-01
Last Modified: 2013-06-02
How do I write this in PHP:

$date = "date_format(date_time'%a %c/%e')";

Open in new window

Question by:rgranlund
  • 2
  • 2
  • 2
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39213424
There is something missing in your question like where are you getting this?  PHP has a 'date_format' function but not a "date_time'%a %c/%e'" function.

Also, I recommend that you do not use PHP reserved words like 'date' as variable names.  Can cause problems.

Author Comment

ID: 39213527
How do you "date_format" a variable that is a date?
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39213539
The PHP date() function can format for just about any valid date.  However, what you posted above is not coming from PHP.  Where are you getting it?  What format is it in?  This is clearly not just a PHP question because PHP doesn't have all those functions.  And 'date' formats are not universal, many programs format them differently.
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

LVL 109

Accepted Solution

Ray Paseur earned 230 total points
ID: 39214594
Required reading here:
How do you "date_format" a variable that is a date?
If I am understanding it correctly it sounds like you have a date, perhaps in ISO-8601 format like 2013-06-02 and you would like to see it in a "pretty" format like June 2, 2013.

<?php // RAY_temp_rgranlund.php

// SEE http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28145008.html

$iso_date = '2031-06-02';
$new_date = date('F j, Y', strtotime($iso_date));
echo $new_date;

Open in new window

If I'm not understanding this correctly, please post back. ~Ray

Author Closing Comment

ID: 39214822
Thank you for that.  It made something I'm doing much easier
LVL 109

Expert Comment

by:Ray Paseur
ID: 39214953
Thanks for the points.  Hope the article is helpful to you! ~Ray

Featured Post

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Dynamic Dropdowns 15 32
how to call a remote wordpress to use his  content in a loop 3 32
Wordpress Security 29 48
Echo Multiple values from multiple records 19 39
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
The viewer will learn how to count occurrences of each item in an array.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question