473,396 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to manipulate date?

If I have a date that looks like: 2005-12-07 10:10:00

How could I manipulate it in php to say "Dec, 07, 2005"?

I can separate the string at the space, but don't know where to go from
there....thanks for any suggestions.

Dec 8 '05 #1
5 2755
*** Greg Scharlemann escribió/wrote (7 Dec 2005 17:46:43 -0800):
If I have a date that looks like: 2005-12-07 10:10:00

How could I manipulate it in php to say "Dec, 07, 2005"?


I think it easier to just get the date in unix timestamp format rather than
a string. Afterwards, you can use several PHP date functions to display it,
such as date() or strftime().

I suppose it comes from a MySQL query so try this:

SELECT UNIX_TIMESTAMP(date_field) FROM table
--
-+ Álvaro G. Vicario - Burgos, Spain
++ http://bits.demogracia.com es mi sitio para programadores web
+- http://www.demogracia.com es mi web de humor libre de cloro
--
Dec 8 '05 #3
Greg Scharlemann wrote:
If I have a date that looks like: 2005-12-07 10:10:00

How could I manipulate it in php to say "Dec, 07, 2005"?

I can separate the string at the space, but don't know where to go from
there....thanks for any suggestions.

Here's a method I've used (found it using Google a year or so ago):

$a = '2005-12-07';

$y = $a[0].$a[1].$a[2].$a[3];
$m = $a[5].$a[6];
$d = $a[8].$a[9];
$unixtimestamp = mktime(0, 0, 0, $m, $d, $y);

$display_date = date('F j, Y',$unixtimestamp)

--
*****************************
Chuck Anderson • Boulder, CO
http://www.CycleTourist.com
Integrity is obvious.
The lack of it is common.
*****************************
Dec 8 '05 #4
Greg Scharlemann wrote:
If I have a date that looks like: 2005-12-07 10:10:00

How could I manipulate it in php to say "Dec, 07, 2005"?

I can separate the string at the space, but don't know where to go from
there....thanks for any suggestions.


$unixTimestamp = strtotime ("2005-12-07 10:10:00") ;
echo date("M, d, Y", $unixTimestamp);
Dec 9 '05 #5
NC
Greg Scharlemann wrote:

If I have a date that looks like: 2005-12-07 10:10:00

How could I manipulate it in php to say "Dec, 07, 2005"?


echo date('M d, Y', strtotime('2005-12-07 10:10:00'));

Cheers,
NC

Dec 9 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Kyle Ramsey | last post by:
I would like to construct a script that parses and prints the metadata from a PDF file. This would include the creation date, author, etc. These attributes are listed in the "document properties"...
8
by: Paul | last post by:
This method: static void swap(int a, int b) { int c = a; a = b; b = c; } does not swap the values of a and b over. It doesn't work for String variables either. However the following method...
3
by: Isaac Rodriguez | last post by:
Does anyone know of a Python API to manipulate CAB files? Thanks, -- Isaac Rodriguez SWE Autodesk. ======================================== There are 10 types of people. Those who...
1
by: R Reyes | last post by:
Hi, what is the best way to manipulate MSOffice programs? i understand that regular web pages do not have the permissions (because of safety measures) to open up MS word/excel programs, for...
3
by: Stewart | last post by:
Dear comp.lang.javascript, I have more than once wanted to manipulate the contents of select boxes dynamically, whilst the boxes contain <optgroup> tags. Manipulation of a select box containing...
1
by: Andreas Palm | last post by:
I have the problem that when I write XML from a dataset I get certain columns that are empty not as empty elements, rather not at all. To avoid that I thought I can go to the dataset and easily...
1
by: Chris | last post by:
Hi, I am using: DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, lcQueryName, strFilePathNamE, True ....to export my query data to an existing excel workbook. Then what i need...
2
by: Jeff | last post by:
Can I manipulate the properties of pure HTML controls (i.e. not server side controls) from my aspx.cs Page_Load event? If so, I don't see the control listed by intellisense. I gave the control a...
1
by: jayanthigk2004 | last post by:
Folks, I need a working code to do the following or something similar. I have two icons in the screen. One to indicate right (a tick mark) and one to indicate wrong (a cross). If the user...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.