Jump to content

Recommended Posts

I have a problem with the timestamp fields.

 

In my offline (test) database the timestamp field is formatted in YYYY-MM-DD HH:MM:SS (default 0000-00-00 00:00:00)

 

when I look at the phpmyadmin online I see that the timestamp fields are formatted like YYYYMMDDHHMMSS (default 00000000000000)

 

i just looked at the database version in phpmyadmin and my offline (test) version is

Welcome to phpMyAdmin 2.5.7-pl1

MySQL 4.1.9-max running on localhost

 

and the online version is

Welcome to phpMyAdmin 2.5.6

MySQL 4.0.23-standard running on localhost

 

Is the formatting of the timestamp field an option you can set in the database or did They just change the format from one version to the other ?

 

This is causing some weird problems.

when I try to format my timestamp date into a human readable form with

$postdate = date('l dS F Y', strtotime($Row['HomepagePostDate']));

it works on my offline (test) version but not in my online version.

when I look at the values stored in the online version they look correct

value in the database 20050925184204 (yesterday)

value displayed on website Wednesday 31st December 1969

 

any clever ideas how to solve this ?

anatak

Link to comment
https://forums.phpfreaks.com/topic/2567-timestamp-format/
Share on other sites

yes they are both of timestamp but there is a small difference

this is the offline version (test)

HomepageUpdateDate timestamp Yes CURRENT_TIMESTAMP HomepagePostDate timestamp Yes 0000-00-00 00:00:00

 

this is the online version

HomepageUpdateDate timestamp(14) Yes NULL

HomepagePostDate timestamp(14) Yes 00000000000000

 

so in the online version is says timestamp(14) while in the test version it says timestamp

note also that in the onine version the default for the first timestamp NULL is and in the offline (test) version it is CURRENT_TIMESTAMP

 

but I still wonder why this does not work

[!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]

$postdate = date(\'l dS F Y\', strtotime($Row[\'HomepagePostDate\']))

[/span][!--PHP-Foot--][/div][!--PHP-EFoot--]

 

or are there other functions to format a timestamp date to a human readable format ?(except for writing the function myself off course)

 

kind regards

anatak

Link to comment
https://forums.phpfreaks.com/topic/2567-timestamp-format/#findComment-8521
Share on other sites

You could use MySQL's date formatting functions instead of PHP's as a workaround. I don't have my reference booklet with me here, but you can look it up in the MySQL manual. For my part I prefer to do all date and time manipulations within MySQL as part of my queries, so that I directly get formatted dates and times the way I need it out of my result sets.

Link to comment
https://forums.phpfreaks.com/topic/2567-timestamp-format/#findComment-8522
Share on other sites

thank you.

I will use the mysql date time functions for this.

 

date_format($TableName1.ReviewUpdateDate, '%M %D, %Y') as updatedate,

 

now I only have to figure out the timezone of my server and then try to solve the difference but I saw some really interesting time functions in mysql I was not aware of.

 

hehe you learn every day and it never stops does it ?

 

thanks again I ran some tests and I feel fairly sure this will solve my problems.

anatak

Link to comment
https://forums.phpfreaks.com/topic/2567-timestamp-format/#findComment-8523
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.