Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Variable into datetime Format

Posted on 2013-06-01
6
Medium Priority
?
172 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 84

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 84

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
Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

 
LVL 111

Accepted Solution

by:
Ray Paseur earned 920 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 111

Expert Comment

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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Does your audience prefer people in photos or no people? How can you best highlight what you’re selling? What are your competitors doing, and what can you do that is different and unique from them?  Continue reading to learn how to make your images …
This article was originally published on Monitis Blog, you can check it here . Today it’s fairly well known that high-performing websites and applications bring in more visitors, higher SEO, and ultimately more sales. By the same token, downtime…
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 create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

688 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