Sponsored By
Advertise with Us
Advertisement
Advertise with Us
Follow Us
Article
Forum
Blog
Quiz
Beginner
Careers
Contact
Login
Email Id
Password
Remember Me
Forgot Password?
Sign Up
Home
|
Product
|
Services
|
About Us
|
Interview
|
DeveloperSection
|
Submit an Article
|
Submit Blog
Report Abuse Form
Reason:
Home
>>
Other Programming
>>
PHP
>>
problem in work with dates in the following format
Author
Post
Rajesh Goswami
Total Post:
29
Member Since:
10/19/2010
Points:
151
problem in work with dates in the following format
Posted On:
11/25/2010 9:19:11 AM
Report Abuse
work with dates in the following format: "Tuesday, February 14, 2006 @ 10:39 am", how can we convert them to another format, that is easier to use? please give the example
Reply
Author
Post
Amit Singh
Total Post:
104
Member Since:
8/8/2010
Points:
702
Re: problem in work with dates in the following format
Posted On:
11/25/2010 9:22:31 AM
Report Abuse
The
strtotime
function can convert a string to a timestamp. A timestamp can be converted to date format. So it is best to store the dates as timestamp in the database, and just output them in the format you like.
So let's say we have
$date = "Tuesday, February 14, 2006 @ 10:39 am";
In order to convert that to a timestamp, we need to get rid of the "@" sign, and we can use the remaining string as a parameter for the strtotime function.
for example
$date = "Tuesday, February 14, 2006 @ 10:39 am";
$date = str_replace("@ ","",$date);
$date = strtotime($date);
now $date is a timestamp
and we can say:
echo date("d M Y",$date);
hi, rajesh check this sample
Reply
Report Abuse Form
Reason:
Total Online Users:
6978
Advertisement
Advertise with Us
Copyright ©
2009 - 2013
MindStick. All Rights Reserved.
Home
|
Contact Us
|
Services
|
Feedback
|
Advertisement
|
Privacy Policy
|
Term & Conditions
|
About Us