Solved

Variable into datetime Format

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

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

Open in new window

0
Comment
Question by:rgranlund
[X]
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
  • 2
  • 2
  • 2
6 Comments
 
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.
0
 
LVL 7

Author Comment

by:rgranlund
ID: 39213527
How do you "date_format" a variable that is a date?
0
 
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.
0
Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

 
LVL 110

Accepted Solution

by:
Ray Paseur earned 230 total points
ID: 39214594
Required reading here:
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_201-Handling-date-and-time-in-PHP-and-MySQL.html
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.
http://www.laprbass.com/RAY_temp_rgranlund.php

<?php // RAY_temp_rgranlund.php
error_reporting(E_ALL);

// 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
0
 
LVL 7

Author Closing Comment

by:rgranlund
ID: 39214822
Thank you for that.  It made something I'm doing much easier
0
 
LVL 110

Expert Comment

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

734 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