1
przemeks
[news] Date format
  • 2005/1/29 10:05

  • przemeks

  • Just popping in

  • Posts: 57

  • Since: 2005/1/29


Hello guys (sorry, i'm from Polnad and my English probably isn't very good :) ) i have problem, because i have site on CMS MD-pro and format date of publish news in table is: '2004-11-14 16:45:10'

And my question is: How to convert this time format to XOOPS format (like this: 1106729433)

2
Catzwolf
Re: [news] Date format
  • 2005/1/29 11:02

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


Hi,

Welcome to XOOPS =)

You need to use 'strtotime()' to convert this to a unix timestamp format.

ie:
$_date = "Mon 29-Jan-2005";

$_time = strtotime($_date);

This will give you want you want.

ATB

Catz

3
przemeks
Re: [news] Date format
  • 2005/1/29 11:31

  • przemeks

  • Just popping in

  • Posts: 57

  • Since: 2005/1/29


Thank you very much, maybe you have any idea how to automatically change this time value in above 100 records :)

4
Catzwolf
Re: [news] Date format
  • 2005/1/29 12:40

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


I think that you might be able to do this with a MySQL command, but I am not 100% sure. I suppose the other way would be to use a script to clone and lock the database tables, change the field type and copt the timestamp over but I think that this would be the long way round.

Maybe you should try asking in a dedicated MySQL forum regarding this or someone else here might be able to help?

ATB

Catz

5
Dave_L
Re: [news] Date format
  • 2005/1/29 13:17

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


This should do what you want:

UPDATE tablename SET columnname UNIX_TIMESTAMP(columnname)


Replace tablename and columnname by the correct names.

Ensure that you backup the database before trying it.

Reference: MySQL Date and Time Functions

6
Catzwolf
Re: [news] Date format
  • 2005/1/29 13:21

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


Thanx Dave_L,

I knew there was an easier option

7
przemeks
Re: [news] Date format
  • 2005/1/31 8:47

  • przemeks

  • Just popping in

  • Posts: 57

  • Since: 2005/1/29


Quote:

Catzwolf wrote:
I think that you might be able to do this with a MySQL command, but I am not 100% sure. I suppose the other way would be to use a script to clone and lock the database tables, change the field type and copt the timestamp over but I think that this would be the long way round.

Maybe you should try asking in a dedicated MySQL forum regarding this or someone else here might be able to help?

ATB

Catz


Thank you very much it works.
Maybe you know how to duplicate one row with values, because in XOOPS table has two rows for date (created and published) in MD-pro is only one :)

Login

Who's Online

150 user(s) are online (101 user(s) are browsing Support Forums)


Members: 0


Guests: 150


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Dec 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits