Solved

Variable into datetime Format

Posted on 2013-06-01
6
169 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
More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

 
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

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

Question has a verified solution.

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

CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
The viewer will learn how to dynamically set the form action using jQuery.

617 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