[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

phpMyAdmin - Timestamp

Posted on 2009-12-17
8
Medium Priority
?
948 Views
Last Modified: 2013-12-12
I am using a timestamp field within phpMyAdmin, but I was wondering if I can control the way the time and date is formatted?

I am currently getting this:  2009-12-17 08:24:34

Ideally I would like: 17-12-2009 08:24:34

i.e. Date, Month and then Year.

Is it possible to edit this?
0
Comment
Question by:petewinter
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 15

Expert Comment

by:Insoftservice
ID: 26069869
HI ,
Do you want to change default time stamp of mysql . or in coding of both mysql and php
0
 
LVL 14

Expert Comment

by:profya
ID: 26069881
MySQL date saved in the database as YYYY-MM-DD HH:NN:SS by default, I don't think you can change the way the data is saved, however, you can change the format later in the user interface. You can also change the field type to char for example and save the date as a string using the format you like.
0
 

Author Comment

by:petewinter
ID: 26069903
Thanks for your replies. If I can't change it in MySQL. Can I change the way it prints on a web page? If so how do I do this?
0
Industry Leaders: 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!

 
LVL 14

Expert Comment

by:profya
ID: 26069940
You can use date function, but before you can use this function you need to convert your mysql date to unix timestamp using list function for example.
0
 
LVL 14

Accepted Solution

by:
profya earned 1200 total points
ID: 26069952
This is an example:
<?php
$date="2009-12-17 08:24:34";
$split=explode(" ", $date);
$newDate=trim($split[0]).' '. trim($split[1]);
$unixDate=strtotime($newDate);
echo date("d-m-Y H:n:s", $unixDate);
?>
0
 
LVL 26

Assisted Solution

by:Umesh
Umesh earned 400 total points
ID: 26069956
Try this..

SELECT DATE_FORMAT('2009-12-17 08:24:34','%d-%m-%Y %H:%m:%s')

17-12-2009 08:24:34

Need to use DATE_FORMAT function for that

http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format
0
 
LVL 15

Assisted Solution

by:Insoftservice
Insoftservice earned 400 total points
ID: 26069975
hi,

http://www.tutorialspoint.com/php/php_function_date_format.htm
http://selectall.wordpress.com/2007/11/12/format-date-values-in-mysql-query/


   DATE_FORMAT(NOW(),'%d/%m%y  %h:%i %s') in mysql

For todays date



<?php
echo(date("m/d/y",mktime(0,0,0,12,36,2001))."<br />");
?>

o/p  12/36/01  
mktime(hour,minute,second,month,day,year,is_dst);
0
 

Author Closing Comment

by:petewinter
ID: 31667206
Thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses
Course of the Month19 days, 20 hours left to enroll

872 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